﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Media; 

namespace elevator
{
    public partial class ElevatorSimulator : Form
    {
        /* Constant variables */
        private readonly string FIRST_FLOOR_UP_BTTN = "up1";
        private readonly string SECOND_FLOOR_DOWN_BTTN = "down2";
        private readonly string SECOND_FLOOR_UP_BTTN = "up2";
        private readonly string THIRD_FLOOR_DOWN_BTTN = "down3";
        private readonly string THIRD_FLOOR_UP_BTTN = "up3";
        private readonly string FOURTH_FLOOR_DOWN_BTTN = "down4";
        private readonly string FOURTH_FLOOR_UP_BTTN = "up4";
        private readonly string FIFTH_FLOOR_DOWN_BTTN = "down5";

        private readonly string INTERNAL_LIFT1_FL1 = "lift1_floor1";
        private readonly string INTERNAL_LIFT1_FL2 = "lift1_floor2";
        private readonly string INTERNAL_LIFT1_FL3 = "lift1_floor3";
        private readonly string INTERNAL_LIFT1_FL4 = "lift1_floor4";
        private readonly string INTERNAL_LIFT1_FL5 = "lift1_floor5";

        private readonly string INTERNAL_LIFT2_FL1 = "lift2_floor1";
        private readonly string INTERNAL_LIFT2_FL2 = "lift2_floor2";
        private readonly string INTERNAL_LIFT2_FL3 = "lift2_floor3";
        private readonly string INTERNAL_LIFT2_FL4 = "lift2_floor4";
        private readonly string INTERNAL_LIFT2_FL5 = "lift2_floor5";

        private readonly string INTERNAL_LIFT3_FL1 = "lift3_floor1";
        private readonly string INTERNAL_LIFT3_FL2 = "lift3_floor2";
        private readonly string INTERNAL_LIFT3_FL3 = "lift3_floor3";
        private readonly string INTERNAL_LIFT3_FL4 = "lift3_floor4";
        private readonly string INTERNAL_LIFT3_FL5 = "lift3_floor5";

        private string simName = ""; 

        private int cycleNo = 0;

        private int totalTimeElapsed = 0; 

        private static int personID = 0;

        int maxFloors = 5; 

        Elevator e1;
        Elevator e2;
        Elevator e3;

        List<String[]> simulationRecording = new List<string[]>();
        List<String[]> loadedSimulation = new List<String[]>(); 

        List<Person> listFirstFloorWaitingPerson1 = new List<Person>();
        List<Person> listFirstFloorWaitingPerson2 = new List<Person>();
        List<Person> listSecondFloorWaitingPerson1 = new List<Person>();
        List<Person> listSecondFloorWaitingPerson2 = new List<Person>();
        List<Person> listThirdFloorWaitingPerson1 = new List<Person>();
        List<Person> listThirdFloorWaitingPerson2 = new List<Person>();
        List<Person> listFourthFloorWaitingPerson1 = new List<Person>();
        List<Person> listFourthFloorWaitingPerson2 = new List<Person>();
        List<Person> listFifthFloorWaitingPerson1 = new List<Person>();
        List<Person> listFifthFloorWaitingPerson2 = new List<Person>();

        List<Person> listFirstFloorDeparted = new List<Person>();
        List<Person> listSecondFloorDeparted = new List<Person>();
        List<Person> listThirdFloorDeparted = new List<Person>();
        List<Person> listFourthFloorDeparted = new List<Person>();
        List<Person> listFifthFloorDeparted = new List<Person>();

        public ElevatorSimulator()
        {
            InitializeComponent();

            e1 = new Elevator(panelLift1, panelLiftUI1);
            e2 = new Elevator(panelLift2, panelLiftUI2);
            e3 = new Elevator(panelLift3, panelLiftUI3);

            setupFloorNaming();

            setupSavedSims(); 
            //e1.openDoors();
            //e2.openDoors(); 
        }
        private void setupSavedSims()
        {
            savedSims.Items.Clear(); 
            List<String> simNames = new MySQLConnector().getSimNames();
            foreach (String simName in simNames)
            {
                savedSims.Items.Add(simName); 
            }
        }
        public void setSimName(string name)
        {
            simName = name; 
        }

        /* The following controls relate to AdminUI - settting up the program */
        private void bttnSetup_Click(object sender, EventArgs e)
        {
            setupNumberLifts(); // show 1, 2, or 3 lifts
            setupNumberFloors(); // show 1, 2, 3, 4, or 5 floors
            setupFloorNaming(); // show either UK or US naming
            resetLifts(); // move the elevators back to floor 1
        }
        private void setupNumberLifts()
        {
            if (radio1lift.Checked)
            {
                panelShaft2.Hide();
                panelShaft3.Hide();
                panelLiftUI2.Hide();
                panelLiftUI3.Hide();
            }
            else if (radio2lifts.Checked)
            {
                panelShaft2.Show();
                panelShaft3.Hide();
                panelLiftUI2.Show();
                panelLiftUI3.Hide();
            }
            else if (radio3lifts.Checked)
            {
                panelShaft2.Show();
                panelShaft3.Show();
                panelLiftUI2.Show();
                panelLiftUI3.Show();
            }
        }
        private void setupNumberFloors()
        {
            if (radio2floors.Checked)
            {
                panelFloor2.Show();
                panelFloor3.Hide();
                panelFloor4.Hide();
                panelFloor5.Hide();

                bttnLiftUI1_two.Show();
                bttnLiftUI1_three.Hide();
                bttnLiftUI1_four.Hide();
                bttnLiftUI1_five.Hide();

                bttnLiftUI2_two.Show();
                bttnLiftUI2_three.Hide();
                bttnLiftUI2_four.Hide();
                bttnLiftUI2_five.Hide();

                bttnLiftUI3_two.Show();
                bttnLiftUI3_three.Hide();
                bttnLiftUI3_four.Hide();
                bttnLiftUI3_five.Hide();
                maxFloors = 2; 

            }
            else if (radio3floors.Checked)
            {
                panelFloor2.Show();
                panelFloor3.Show();
                panelFloor4.Hide();
                panelFloor5.Hide();

                bttnLiftUI1_two.Show();
                bttnLiftUI1_three.Show();
                bttnLiftUI1_four.Hide();
                bttnLiftUI1_five.Hide();

                bttnLiftUI2_two.Show();
                bttnLiftUI2_three.Show();
                bttnLiftUI2_four.Hide();
                bttnLiftUI2_five.Hide();

                bttnLiftUI3_two.Show();
                bttnLiftUI3_three.Show();
                bttnLiftUI3_four.Hide();
                bttnLiftUI3_five.Hide();
                maxFloors = 3; 
            }
            else if (radio4floors.Checked)
            {
                panelFloor2.Show();
                panelFloor3.Show();
                panelFloor4.Show();
                panelFloor5.Hide();

                bttnLiftUI1_two.Show();
                bttnLiftUI1_three.Show();
                bttnLiftUI1_four.Show();
                bttnLiftUI1_five.Hide();

                bttnLiftUI2_two.Show();
                bttnLiftUI2_three.Show();
                bttnLiftUI2_four.Show();
                bttnLiftUI2_five.Hide();

                bttnLiftUI3_two.Show();
                bttnLiftUI3_three.Show();
                bttnLiftUI3_four.Show();
                bttnLiftUI3_five.Hide();
                maxFloors = 4;
            }
            else if (radio5floors.Checked)
            {
                panelFloor2.Show();
                panelFloor3.Show();
                panelFloor4.Show();
                panelFloor5.Show();

                bttnLiftUI1_two.Show();
                bttnLiftUI1_three.Show();
                bttnLiftUI1_four.Show();
                bttnLiftUI1_five.Show();

                bttnLiftUI2_two.Show();
                bttnLiftUI2_three.Show();
                bttnLiftUI2_four.Show();
                bttnLiftUI2_five.Show();

                bttnLiftUI3_two.Show();
                bttnLiftUI3_three.Show();
                bttnLiftUI3_four.Show();
                bttnLiftUI3_five.Show();
                maxFloors = 5; 
            }
        }
        private void setupFloorNaming()
        {
            if (radioUK.Checked)
            {
                lblFloor1.Text = "G";
                lblFloor2.Text = "1";
                lblFloor3.Text = "2";
                lblFloor4.Text = "3";
                lblFloor5.Text = "4";

                bttnLiftUI1_one.Text = "G";
                bttnLiftUI1_two.Text = "1";
                bttnLiftUI1_three.Text = "2";
                bttnLiftUI1_four.Text = "3";
                bttnLiftUI1_five.Text = "4";

                bttnLiftUI2_one.Text = "G";
                bttnLiftUI2_two.Text = "1";
                bttnLiftUI2_three.Text = "2";
                bttnLiftUI2_four.Text = "3";
                bttnLiftUI2_five.Text = "4";

                bttnLiftUI3_one.Text = "G";
                bttnLiftUI3_two.Text = "1";
                bttnLiftUI3_three.Text = "2";
                bttnLiftUI3_four.Text = "3";
                bttnLiftUI3_five.Text = "4";
            }
            else if (radioUS.Checked)
            {
                lblFloor1.Text = "1";
                lblFloor2.Text = "2";
                lblFloor3.Text = "3";
                lblFloor4.Text = "4";
                lblFloor5.Text = "5";

                bttnLiftUI1_one.Text = "1";
                bttnLiftUI1_two.Text = "2";
                bttnLiftUI1_three.Text = "3";
                bttnLiftUI1_four.Text = "4";
                bttnLiftUI1_five.Text = "5";

                bttnLiftUI2_one.Text = "1";
                bttnLiftUI2_two.Text = "2";
                bttnLiftUI2_three.Text = "3";
                bttnLiftUI2_four.Text = "4";
                bttnLiftUI2_five.Text = "5";

                bttnLiftUI3_one.Text = "1";
                bttnLiftUI3_two.Text = "2";
                bttnLiftUI3_three.Text = "3";
                bttnLiftUI3_four.Text = "4";
                bttnLiftUI3_five.Text = "5";
            }
        }
        private void resetLifts()
        {
            e1.reset(3, 339);
            e2.reset(3, 339);
            e3.reset(3, 339);


            turnInternalLightOff(INTERNAL_LIFT1_FL1);
            turnInternalLightOff(INTERNAL_LIFT1_FL2);
            turnInternalLightOff(INTERNAL_LIFT1_FL3);
            turnInternalLightOff(INTERNAL_LIFT1_FL4);
            turnInternalLightOff(INTERNAL_LIFT1_FL5);

            turnInternalLightOff(INTERNAL_LIFT2_FL1);
            turnInternalLightOff(INTERNAL_LIFT2_FL2);
            turnInternalLightOff(INTERNAL_LIFT2_FL3);
            turnInternalLightOff(INTERNAL_LIFT2_FL4);
            turnInternalLightOff(INTERNAL_LIFT2_FL5);

            turnInternalLightOff(INTERNAL_LIFT3_FL1);
            turnInternalLightOff(INTERNAL_LIFT3_FL2);
            turnInternalLightOff(INTERNAL_LIFT3_FL3);
            turnInternalLightOff(INTERNAL_LIFT3_FL4);
            turnInternalLightOff(INTERNAL_LIFT3_FL5);
        }
        /* End AdminUI controls */

        /* The following controls relate to LiftUI */
        private void bttnLiftUI1_one_Click(object sender, EventArgs e)
        {
            internalButtonPressed(INTERNAL_LIFT1_FL1);
        }
        private void bttnLiftUI1_two_Click(object sender, EventArgs e)
        {
            internalButtonPressed(INTERNAL_LIFT1_FL2);
        }
        private void bttnLiftUI1_three_Click(object sender, EventArgs e)
        {
            internalButtonPressed(INTERNAL_LIFT1_FL3);
        }
        private void bttnLiftUI1_four_Click(object sender, EventArgs e)
        {
            internalButtonPressed(INTERNAL_LIFT1_FL4);
        }
        private void bttnLiftUI1_five_Click(object sender, EventArgs e)
        {
            internalButtonPressed(INTERNAL_LIFT1_FL5);
        }
        private void bttnLiftUI2_one_Click(object sender, EventArgs e)
        {
            internalButtonPressed(INTERNAL_LIFT2_FL1);
        }
        private void bttnLiftUI2_two_Click(object sender, EventArgs e)
        {
            internalButtonPressed(INTERNAL_LIFT2_FL2);
        }
        private void bttnLiftUI2_three_Click(object sender, EventArgs e)
        {
            internalButtonPressed(INTERNAL_LIFT2_FL3);
        }
        private void bttnLiftUI2_four_Click(object sender, EventArgs e)
        {
            internalButtonPressed(INTERNAL_LIFT2_FL4);
        }
        private void bttnLiftUI2_five_Click(object sender, EventArgs e)
        {
            internalButtonPressed(INTERNAL_LIFT2_FL5);
        }
        private void bttnLiftUI3_one_Click(object sender, EventArgs e)
        {
            internalButtonPressed(INTERNAL_LIFT3_FL1);
        }
        private void bttnLiftUI3_two_Click(object sender, EventArgs e)
        {
            internalButtonPressed(INTERNAL_LIFT3_FL2);
        }
        private void bttnLiftUI3_three_Click(object sender, EventArgs e)
        {
            internalButtonPressed(INTERNAL_LIFT3_FL3);
        }
        private void bttnLiftUI3_four_Click(object sender, EventArgs e)
        {
            internalButtonPressed(INTERNAL_LIFT3_FL4);
        }
        private void bttnLiftUI3_five_Click(object sender, EventArgs e)
        {
            internalButtonPressed(INTERNAL_LIFT3_FL5);
        }

        private void internalButtonPressed(string bttn)
        {
            turnInternalLightOn(bttn);

            string command = "";
            if (bttn.Contains("floor1"))
            {
                command = "floor1";
            }
            else if (bttn.Contains("floor2"))
            {
                command = "floor2";
            }
            else if (bttn.Contains("floor3"))
            {
                command = "floor3";
            }
            else if (bttn.Contains("floor4"))
            {
                command = "floor4";
            }
            else if (bttn.Contains("floor5"))
            {
                command = "floor5";
            }


            if (bttn.Contains("lift1"))
            {
                e1.addNewCommand(command);
            }
            else if (bttn.Contains("lift2"))
            {
                e2.addNewCommand(command);
            }
            else if (bttn.Contains("lift3"))
            {
                e3.addNewCommand(command);
            }
        }

        private void turnInternalLightOn(string bttn)
        {
            if (bttn.Equals(INTERNAL_LIFT1_FL1))
            {
                bttnLiftUI1_one.ForeColor = Color.Yellow;
            }
            else if (bttn.Equals(INTERNAL_LIFT1_FL2))
            {
                bttnLiftUI1_two.ForeColor = Color.Yellow;
            }
            else if (bttn.Equals(INTERNAL_LIFT1_FL3))
            {
                bttnLiftUI1_three.ForeColor = Color.Yellow;
            }
            else if (bttn.Equals(INTERNAL_LIFT1_FL4))
            {
                bttnLiftUI1_four.ForeColor = Color.Yellow;
            }
            else if (bttn.Equals(INTERNAL_LIFT1_FL5))
            {
                bttnLiftUI1_five.ForeColor = Color.Yellow;
            }
            else if (bttn.Equals(INTERNAL_LIFT2_FL1))
            {
                bttnLiftUI2_one.ForeColor = Color.Yellow;
            }
            else if (bttn.Equals(INTERNAL_LIFT2_FL2))
            {
                bttnLiftUI2_two.ForeColor = Color.Yellow;
            }
            else if (bttn.Equals(INTERNAL_LIFT2_FL3))
            {
                bttnLiftUI2_three.ForeColor = Color.Yellow;
            }
            else if (bttn.Equals(INTERNAL_LIFT2_FL4))
            {
                bttnLiftUI2_four.ForeColor = Color.Yellow;
            }
            else if (bttn.Equals(INTERNAL_LIFT2_FL5))
            {
                bttnLiftUI2_five.ForeColor = Color.Yellow;
            }
            else if (bttn.Equals(INTERNAL_LIFT3_FL1))
            {
                bttnLiftUI3_one.ForeColor = Color.Yellow;
            }
            else if (bttn.Equals(INTERNAL_LIFT3_FL2))
            {
                bttnLiftUI3_two.ForeColor = Color.Yellow;
            }
            else if (bttn.Equals(INTERNAL_LIFT3_FL3))
            {
                bttnLiftUI3_three.ForeColor = Color.Yellow;
            }
            else if (bttn.Equals(INTERNAL_LIFT3_FL4))
            {
                bttnLiftUI3_four.ForeColor = Color.Yellow;
            }
            else if (bttn.Equals(INTERNAL_LIFT3_FL5))
            {
                bttnLiftUI3_five.ForeColor = Color.Yellow;
            }
        }
        private void turnInternalLightOff(string bttn)
        {
            if (bttn.Equals(INTERNAL_LIFT1_FL1))
            {
                bttnLiftUI1_one.ForeColor = Color.Black;
            }
            else if (bttn.Equals(INTERNAL_LIFT1_FL2))
            {
                bttnLiftUI1_two.ForeColor = Color.Black;
            }
            else if (bttn.Equals(INTERNAL_LIFT1_FL3))
            {
                bttnLiftUI1_three.ForeColor = Color.Black;
            }
            else if (bttn.Equals(INTERNAL_LIFT1_FL4))
            {
                bttnLiftUI1_four.ForeColor = Color.Black;
            }
            else if (bttn.Equals(INTERNAL_LIFT1_FL5))
            {
                bttnLiftUI1_five.ForeColor = Color.Black;
            }
            else if (bttn.Equals(INTERNAL_LIFT2_FL1))
            {
                bttnLiftUI2_one.ForeColor = Color.Black;
            }
            else if (bttn.Equals(INTERNAL_LIFT2_FL2))
            {
                bttnLiftUI2_two.ForeColor = Color.Black;
            }
            else if (bttn.Equals(INTERNAL_LIFT2_FL3))
            {
                bttnLiftUI2_three.ForeColor = Color.Black;
            }
            else if (bttn.Equals(INTERNAL_LIFT2_FL4))
            {
                bttnLiftUI2_four.ForeColor = Color.Black;
            }
            else if (bttn.Equals(INTERNAL_LIFT2_FL5))
            {
                bttnLiftUI2_five.ForeColor = Color.Black;
            }
            else if (bttn.Equals(INTERNAL_LIFT3_FL1))
            {
                bttnLiftUI3_one.ForeColor = Color.Black;
            }
            else if (bttn.Equals(INTERNAL_LIFT3_FL2))
            {
                bttnLiftUI3_two.ForeColor = Color.Black;
            }
            else if (bttn.Equals(INTERNAL_LIFT3_FL3))
            {
                bttnLiftUI3_three.ForeColor = Color.Black;
            }
            else if (bttn.Equals(INTERNAL_LIFT3_FL4))
            {
                bttnLiftUI3_four.ForeColor = Color.Black;
            }
            else if (bttn.Equals(INTERNAL_LIFT3_FL5))
            {
                bttnLiftUI3_five.ForeColor = Color.Black;
            }
        }

        /* The following controls relate to FloorUI */
        private void bttnUp1_Click(object sender, EventArgs e)
        {
            buttonPressed(FIRST_FLOOR_UP_BTTN);
        } // up1
        private void bttnDown2_Click(object sender, EventArgs e)
        {
            buttonPressed(SECOND_FLOOR_DOWN_BTTN);
        } // down2
        private void bttnUp2_Click(object sender, EventArgs e)
        {
            buttonPressed(SECOND_FLOOR_UP_BTTN);
        }  // up2
        private void bttnDown3_Click(object sender, EventArgs e)
        {
            buttonPressed(THIRD_FLOOR_DOWN_BTTN);
        } // down3
        private void bttnUp3_Click(object sender, EventArgs e)
        {
            buttonPressed(THIRD_FLOOR_UP_BTTN);
        } // up3
        private void bttnDown4_Click(object sender, EventArgs e)
        {
            buttonPressed(FOURTH_FLOOR_DOWN_BTTN);
        } // down4
        private void bttnUp4_Click(object sender, EventArgs e)
        {
            buttonPressed(FOURTH_FLOOR_UP_BTTN);
        } // up4
        private void bttnDown5_Click(object sender, EventArgs e)
        {
            buttonPressed(FIFTH_FLOOR_DOWN_BTTN);
        } // down5

        private void buttonPressed(string bttn)
        {
            turnLightOn(bttn);
            string lift = findBestElevator();
            if (lift.Contains("lift1"))
            {
                e1.addNewCommand(bttn);
            }
            else if (lift.Contains("lift2"))
            {
                e2.addNewCommand(bttn);
            }
            else if (lift.Contains("lift3"))
            {
                e3.addNewCommand(bttn); 
            }


            ///* CALCULATE RANDOM ELEVATOR HERE */
            //Random random = new Random();
            //int max = 1;
            //if (radio1lift.Checked) { max = 1; }
            //if (radio2lifts.Checked) { max = 2; }
            //if (radio3lifts.Checked) { max = 3; }
            //int randomLift = random.Next(0, max);
            //if (randomLift == 0)
            //{
            //    e1.addNewCommand(bttn);
            //}
            //else if (randomLift == 1)
            //{
            //    e2.addNewCommand(bttn);
            //}
            //else if (randomLift == 2)
            //{
            //    e3.addNewCommand(bttn);
            //}
        } // Commands for when a button is pressed
        private string findBestElevator()
        {
            if (radio1lift.Checked)
            {
                return "lift1";
            }
            else if (radio2lifts.Checked)
            {
                int e1Occupants = 0;
                int e2Occupants = 0;

                List<string> findSmallest = new List<string>();

                e1Occupants += e1.getOccupantList(1).Count;
                e1Occupants += e1.getOccupantList(2).Count;

                e2Occupants += e2.getOccupantList(1).Count;
                e2Occupants += e2.getOccupantList(2).Count;

                if (e1Occupants == e2Occupants)
                {
                    Random random = new Random();
                    int randy = random.Next(0, 2);
                    if (randy == 0)
                    {
                        return "lift1";
                    }
                    else if (randy == 1)
                    {
                        return "lift2";
                    }
                }

                string e1n = e1Occupants + "lift1";
                string e2n = e2Occupants + "lift2";

                findSmallest.Add(e1n);
                findSmallest.Add(e2n);

                findSmallest.Sort();

                return findSmallest[0]; 
            }
            else if (radio3lifts.Checked)
            {
                int e1Occupants = 0;
                int e2Occupants = 0;
                int e3Occupants = 0;

                List<string> findSmallest = new List<string>();

                e1Occupants += e1.getOccupantList(1).Count;
                e1Occupants += e1.getOccupantList(2).Count;

                e2Occupants += e2.getOccupantList(1).Count;
                e2Occupants += e2.getOccupantList(2).Count;

                e3Occupants += e3.getOccupantList(1).Count;
                e3Occupants += e3.getOccupantList(2).Count;

                if (e1Occupants == e2Occupants && e1Occupants == e3Occupants && e2Occupants == e3Occupants)
                {
                    Random random = new Random();
                    int randy = random.Next(0, 3);
                    if (randy == 0)
                    {
                        return "lift1";
                    }
                    else if (randy == 1)
                    {
                        return "lift2";
                    }
                    else
                    {
                        return "lift3";
                    }
                }

                string e1n = e1Occupants + "lift1";
                string e2n = e2Occupants + "lift2";
                string e3n = e3Occupants + "lift3";

                findSmallest.Add(e1n);
                findSmallest.Add(e2n);
                findSmallest.Add(e3n);

                findSmallest.Sort();

                return findSmallest[0];
            }
            return "lift1";
        }
        private void turnLightOn(string bttn)
        {
            if (bttn.Equals(FIRST_FLOOR_UP_BTTN))
            {
                bttnUp1.Image = Properties.Resources.up_button_lit;
            }
            else if (bttn.Equals(SECOND_FLOOR_DOWN_BTTN))
            {
                bttnDown2.Image = Properties.Resources.down_button_lit;
            }
            else if (bttn.Equals(SECOND_FLOOR_UP_BTTN))
            {
                bttnUp2.Image = Properties.Resources.up_button_lit;
            }
            else if (bttn.Equals(THIRD_FLOOR_DOWN_BTTN))
            {
                bttnDown3.Image = Properties.Resources.down_button_lit;
            }
            else if (bttn.Equals(THIRD_FLOOR_UP_BTTN))
            {
                bttnUp3.Image = Properties.Resources.up_button_lit;
            }
            else if (bttn.Equals(FOURTH_FLOOR_DOWN_BTTN))
            {
                bttnDown4.Image = Properties.Resources.down_button_lit;
            }
            else if (bttn.Equals(FOURTH_FLOOR_UP_BTTN))
            {
                bttnUp4.Image = Properties.Resources.up_button_lit;
            }
            else if (bttn.Equals(FIFTH_FLOOR_DOWN_BTTN))
            {
                bttnDown5.Image = Properties.Resources.down_button_lit;
            }
        }
        private void turnLightOff(string bttn)
        {
            if (bttn.Equals(FIRST_FLOOR_UP_BTTN))
            {
                bttnUp1.Image = Properties.Resources.up_button;
            }
            else if (bttn.Equals(SECOND_FLOOR_DOWN_BTTN))
            {
                bttnDown2.Image = Properties.Resources.down_button;
            }
            else if (bttn.Equals(SECOND_FLOOR_UP_BTTN))
            {
                bttnUp2.Image = Properties.Resources.up_button;
            }
            else if (bttn.Equals(THIRD_FLOOR_DOWN_BTTN))
            {
                bttnDown3.Image = Properties.Resources.down_button;
            }
            else if (bttn.Equals(THIRD_FLOOR_UP_BTTN))
            {
                bttnUp3.Image = Properties.Resources.up_button;
            }
            else if (bttn.Equals(FOURTH_FLOOR_DOWN_BTTN))
            {
                bttnDown4.Image = Properties.Resources.down_button;
            }
            else if (bttn.Equals(FOURTH_FLOOR_UP_BTTN))
            {
                bttnUp4.Image = Properties.Resources.up_button;
            }
            else if (bttn.Equals(FIFTH_FLOOR_DOWN_BTTN))
            {
                bttnDown5.Image = Properties.Resources.down_button;
            }
        }

        /* Constantly checks for the position of each elevator and updates as necessary */
        private void graphicUpdater_Tick(object sender, EventArgs e)
        {
            e1.updateLiftPosition();
            e2.updateLiftPosition();
            e3.updateLiftPosition();
        }

        /* schedules the movement of each elevator */
        private void e1scheduler_Tick(object sender, EventArgs e)
        {
            /* up1 up1 up1 up1 up1 up1 up1 up1 up1 up1 up1 up1 */
            if (e1.getNextCommand().Equals("up1"))
            {
                if (e1.getCurrentFloor() == 1)
                {
                    e1.removeCommand("up1");
                    turnLightOff(FIRST_FLOOR_UP_BTTN);
                    e1.setCurrentFloor(1);
                    e1.openDoors();
                    e1.setMovingDirection("stopped"); 
                    departPersons(1, 1);
                    boardPersons(1, 1);
                }
                else if (e1.getCurrentFloor() == 2 || e1.getCurrentFloor() == 3 || e1.getCurrentFloor() == 4 || e1.getCurrentFloor() == 5)
                {
                    if (e1.getPanel().Location.Y < 339)
                    {
                        if (e1.getDoorStatus().Equals("open"))
                        {
                            e1.closeDoors();
                        }
                        else if (e1.getDoorStatus().Equals("closed"))
                        {
                            e1.moveLift("down");
                            e1.setMovingDirection("down"); 
                        }
                    }
                    else
                    {
                        e1.removeCommand("up1");
                        turnLightOff(FIRST_FLOOR_UP_BTTN);
                        e1.setCurrentFloor(1);
                        e1.setMovingDirection("stopped"); 
                        e1.openDoors();
                        departPersons(1, 1);
                        boardPersons(1, 1);
                    }
                }
            }



            /* down2 down2 down2 down2 down2 down2 down2 down2 */
            if (e1.getNextCommand().Equals("down2"))
            {
                if (e1.getCurrentFloor() == 1)
                {
                    if (e1.getPanel().Location.Y > 252)
                    {
                        if (e1.getDoorStatus().Equals("open"))
                        {
                            e1.closeDoors();
                        }
                        else if (e1.getDoorStatus().Equals("closed"))
                        {
                            e1.moveLift("up");
                            e1.setMovingDirection("up"); 
                        }
                    }
                    else
                    {
                        e1.removeCommand("down2");
                        turnLightOff(SECOND_FLOOR_DOWN_BTTN);
                        e1.setCurrentFloor(2);
                        e1.openDoors();
                        e1.setMovingDirection("stopped"); 
                        departPersons(2, 1);
                        boardPersons(2, 1);
                    }
                }
                else if (e1.getCurrentFloor() == 2)
                {
                    e1.removeCommand("down2");
                    turnLightOff(SECOND_FLOOR_DOWN_BTTN);
                    e1.setCurrentFloor(2);
                    e1.setMovingDirection("stopped"); 
                    e1.openDoors();
                    departPersons(2, 1);
                    boardPersons(2, 1);
                }
                else if (e1.getCurrentFloor() == 3 || e1.getCurrentFloor() == 4 || e1.getCurrentFloor() == 5)
                {
                    if (e1.getPanel().Location.Y < 252)
                    {
                        if (e1.getDoorStatus().Equals("open"))
                        {
                            e1.closeDoors();
                        }
                        else if (e1.getDoorStatus().Equals("closed"))
                        {
                            e1.moveLift("down");
                            e1.setMovingDirection("down"); 
                        }
                    }
                    else
                    {
                        e1.removeCommand("down2");
                        turnLightOff(SECOND_FLOOR_DOWN_BTTN);
                        e1.setCurrentFloor(2);
                        e1.openDoors();
                        e1.setMovingDirection("stopped"); 
                        departPersons(2, 1);
                        boardPersons(2, 1);
                    }
                }
            }




            /* up2 up2 up2 up2 up2 up2 up2 up2 up2 up2 up2 up2 */
            if (e1.getNextCommand().Equals("up2"))
            {
                if (e1.getCurrentFloor() == 1)
                {
                    if (e1.getPanel().Location.Y > 252)
                    {
                        if (e1.getDoorStatus().Equals("open"))
                        {
                            e1.closeDoors();
                        }
                        else if (e1.getDoorStatus().Equals("closed"))
                        {
                            e1.moveLift("up");
                            e1.setMovingDirection("up"); 
                        }
                    }
                    else
                    {
                        e1.removeCommand("up2");
                        turnLightOff(SECOND_FLOOR_UP_BTTN);
                        e1.setCurrentFloor(2);
                        e1.openDoors();
                        e1.setMovingDirection("stopped"); 
                        departPersons(2, 1);
                        boardPersons(2, 1);
                    }
                }
                else if (e1.getCurrentFloor() == 2)
                {
                    e1.removeCommand("up2");
                    turnLightOff(SECOND_FLOOR_UP_BTTN);
                    e1.setCurrentFloor(2);
                    e1.openDoors();
                    e1.setMovingDirection("stopped"); 
                    departPersons(2, 1);
                    boardPersons(2, 1);
                }
                else if (e1.getCurrentFloor() == 3 || e1.getCurrentFloor() == 4 || e1.getCurrentFloor() == 5)
                {
                    if (e1.getPanel().Location.Y < 252)
                    {
                        if (e1.getDoorStatus().Equals("open"))
                        {
                            e1.closeDoors();
                        }
                        else if (e1.getDoorStatus().Equals("closed"))
                        {
                            e1.moveLift("down");
                            e1.setMovingDirection("down"); 
                        }
                    }
                    else
                    {
                        e1.removeCommand("up2");
                        turnLightOff(SECOND_FLOOR_UP_BTTN);
                        e1.setCurrentFloor(2);
                        e1.openDoors();
                        e1.setMovingDirection("stopped"); 
                        departPersons(2, 1);
                        boardPersons(2, 1);
                    }
                }
            }



            /* down3 down3 down3 down3 down3 down3 down3 down3 */
            if (e1.getNextCommand().Equals("down3"))
            {
                if (e1.getCurrentFloor() == 1 || e1.getCurrentFloor() == 2)
                {
                    if (e1.getPanel().Location.Y > 171)
                    {
                        if (e1.getDoorStatus().Equals("open"))
                        {
                            e1.closeDoors();
                        }
                        else if (e1.getDoorStatus().Equals("closed"))
                        {
                            e1.moveLift("up");
                            e1.setMovingDirection("up"); 
                        }
                    }
                    else
                    {
                        e1.removeCommand("down3");
                        turnLightOff(THIRD_FLOOR_DOWN_BTTN);
                        e1.setCurrentFloor(3);
                        e1.openDoors();
                        e1.setMovingDirection("stopped"); 
                        departPersons(3, 1);
                        boardPersons(3, 1);
                    }
                }
                else if (e1.getCurrentFloor() == 3)
                {
                    e1.removeCommand("down3");
                    turnLightOff(THIRD_FLOOR_DOWN_BTTN);
                    e1.setCurrentFloor(3);
                    e1.openDoors();
                    e1.setMovingDirection("stopped"); 
                    departPersons(3, 1);
                    boardPersons(3, 1);
                }
                else if (e1.getCurrentFloor() == 4 || e1.getCurrentFloor() == 5)
                {
                    if (e1.getPanel().Location.Y < 171)
                    {
                        if (e1.getDoorStatus().Equals("open"))
                        {
                            e1.closeDoors();
                        }
                        else if (e1.getDoorStatus().Equals("closed"))
                        {
                            e1.moveLift("down");
                            e1.setMovingDirection("down"); 
                        }
                    }
                    else
                    {
                        e1.removeCommand("down3");
                        turnLightOff(THIRD_FLOOR_DOWN_BTTN);
                        e1.setCurrentFloor(3);
                        e1.openDoors();
                        e1.setMovingDirection("stopped"); 
                        departPersons(3, 1);
                        boardPersons(3, 1);
                    }
                }
            }



            /* up3 up3 up3 up3 up3 up3 up3 up3 up3 up3 up3 up3 up3 */
            if (e1.getNextCommand().Equals("up3"))
            {
                if (e1.getCurrentFloor() == 1 || e1.getCurrentFloor() == 2)
                {
                    if (e1.getPanel().Location.Y > 171)
                    {
                        if (e1.getDoorStatus().Equals("open"))
                        {
                            e1.closeDoors();
                        }
                        else if (e1.getDoorStatus().Equals("closed"))
                        {
                            e1.moveLift("up");
                            e1.setMovingDirection("up"); 
                        }
                    }
                    else
                    {
                        e1.removeCommand("up3");
                        turnLightOff(THIRD_FLOOR_UP_BTTN);
                        e1.setCurrentFloor(3);
                        e1.openDoors();
                        e1.setMovingDirection("stopped");
                        departPersons(3, 1);
                        boardPersons(3, 1);
                    }
                }
                else if (e1.getCurrentFloor() == 3)
                {
                    e1.removeCommand("up3");
                    turnLightOff(THIRD_FLOOR_UP_BTTN);
                    e1.setCurrentFloor(3);
                    e1.openDoors();
                    e1.setMovingDirection("stopped"); 
                    departPersons(3, 1);
                    boardPersons(3, 1);
                }
                else if (e1.getCurrentFloor() == 4 || e1.getCurrentFloor() == 5)
                {
                    if (e1.getPanel().Location.Y < 171)
                    {
                        if (e1.getDoorStatus().Equals("open"))
                        {
                            e1.closeDoors();
                        }
                        else if (e1.getDoorStatus().Equals("closed"))
                        {
                            e1.moveLift("down");
                            e1.setMovingDirection("down"); 
                        }
                    }
                    else
                    {
                        e1.removeCommand("up3");
                        turnLightOff(THIRD_FLOOR_UP_BTTN);
                        e1.setCurrentFloor(3);
                        e1.openDoors();
                        e1.setMovingDirection("stopped"); 
                        departPersons(3, 1);
                        boardPersons(3, 1);
                    }
                }
            }



            /* down4 down4 down4 down4 down4 down4 down4 down4 */
            if (e1.getNextCommand().Equals("down4"))
            {
                if (e1.getCurrentFloor() == 1 || e1.getCurrentFloor() == 2 || e1.getCurrentFloor() == 3)
                {
                    if (e1.getPanel().Location.Y > 88)
                    {
                        if (e1.getDoorStatus().Equals("open"))
                        {
                            e1.closeDoors();
                        }
                        else if (e1.getDoorStatus().Equals("closed"))
                        {
                            e1.moveLift("up");
                            e1.setMovingDirection("up"); 
                        }
                    }
                    else
                    {
                        e1.removeCommand("down4");
                        turnLightOff(FOURTH_FLOOR_DOWN_BTTN);
                        e1.setCurrentFloor(4);
                        e1.openDoors();
                        e1.setMovingDirection("stopped"); 
                        departPersons(4, 1);
                        boardPersons(4, 1);
                    }
                }
                else if (e1.getCurrentFloor() == 4)
                {
                    e1.removeCommand("down4");
                    turnLightOff(FOURTH_FLOOR_DOWN_BTTN);
                    e1.setCurrentFloor(4);
                    e1.openDoors();
                    e1.setMovingDirection("stopped"); 
                    departPersons(4, 1);
                    boardPersons(4, 1);
                }
                else if (e1.getCurrentFloor() == 5)
                {
                    if (e1.getPanel().Location.Y < 88)
                    {
                        if (e1.getDoorStatus().Equals("open"))
                        {
                            e1.closeDoors();
                        }
                        else if (e1.getDoorStatus().Equals("closed"))
                        {
                            e1.moveLift("down");
                            e1.setMovingDirection("down"); 
                        }
                    }
                    else
                    {
                        e1.removeCommand("down4");
                        turnLightOff(FOURTH_FLOOR_DOWN_BTTN);
                        e1.setCurrentFloor(4);
                        e1.openDoors();
                        e1.setMovingDirection("stopped"); 
                        departPersons(4, 1);
                        boardPersons(4, 1);
                    }
                }
            }





            /* up4 up4 up4 up4 up4 up4 up4 up4 up4 up4 up4 up4 */
            if (e1.getNextCommand().Equals("up4"))
            {
                if (e1.getCurrentFloor() == 1 || e1.getCurrentFloor() == 2 || e1.getCurrentFloor() == 3)
                {
                    if (e1.getPanel().Location.Y > 88)
                    {
                        if (e1.getDoorStatus().Equals("open"))
                        {
                            e1.closeDoors();
                        }
                        else if (e1.getDoorStatus().Equals("closed"))
                        {
                            e1.moveLift("up");
                            e1.setMovingDirection("up"); 
                        }
                    }
                    else
                    {
                        e1.removeCommand("up4");
                        turnLightOff(FOURTH_FLOOR_UP_BTTN);
                        e1.setCurrentFloor(4);
                        e1.openDoors();
                        e1.setMovingDirection("stopped"); 
                        departPersons(4, 1);
                        boardPersons(4, 1);
                    }
                }
                else if (e1.getCurrentFloor() == 4)
                {
                    e1.removeCommand("up4");
                    turnLightOff(FOURTH_FLOOR_UP_BTTN);
                    e1.setCurrentFloor(4);
                    e1.openDoors();
                    e1.setMovingDirection("stopped"); 
                    departPersons(4, 1);
                    boardPersons(4, 1);
                }
                else if (e1.getCurrentFloor() == 5)
                {
                    if (e1.getPanel().Location.Y < 88)
                    {
                        if (e1.getDoorStatus().Equals("open"))
                        {
                            e1.closeDoors();
                        }
                        else if (e1.getDoorStatus().Equals("closed"))
                        {
                            e1.moveLift("down");
                            e1.setMovingDirection("down"); 
                        }
                    }
                    else
                    {
                        e1.removeCommand("up4");
                        turnLightOff(FOURTH_FLOOR_UP_BTTN);
                        e1.setCurrentFloor(4);
                        e1.openDoors();
                        e1.setMovingDirection("stopped"); 
                        departPersons(4, 1);
                        boardPersons(4, 1);
                    }
                }
            }



            /* down5 down5 down5 down5 down5 down5 down5 down5 down5 */
            if (e1.getNextCommand().Equals("down5"))
            {
                if (e1.getCurrentFloor() == 1 || e1.getCurrentFloor() == 2 || e1.getCurrentFloor() == 3 || e1.getCurrentFloor() == 4)
                {
                    if (e1.getPanel().Location.Y > 1)
                    {
                        if (e1.getDoorStatus().Equals("open"))
                        {
                            e1.closeDoors();
                        }
                        else if (e1.getDoorStatus().Equals("closed"))
                        {
                            e1.moveLift("up");
                            e1.setMovingDirection("up"); 
                        }
                    }
                    else
                    {
                        e1.removeCommand("down5");
                        turnLightOff(FIFTH_FLOOR_DOWN_BTTN);
                        e1.setCurrentFloor(5);
                        e1.openDoors();
                        e1.setMovingDirection("stopped"); 
                        departPersons(5, 1);
                        boardPersons(5, 1);
                    }
                }
                else if (e1.getCurrentFloor() == 5)
                {
                    e1.removeCommand("down5");
                    turnLightOff(FIFTH_FLOOR_DOWN_BTTN);
                    e1.setCurrentFloor(5);
                    e1.openDoors();
                    e1.setMovingDirection("stopped"); 
                    departPersons(5, 1);
                    boardPersons(5, 1);
                }
            }





            /* floor1 floor1 floor1 floor1 floor1 floor1 floor1 floor1 floor1 */
            if (e1.getNextCommand().Equals("floor1"))
            {
                if (e1.getCurrentFloor() == 1)
                {
                    e1.removeCommand("floor1");
                    turnInternalLightOff(INTERNAL_LIFT1_FL1);
                    e1.setCurrentFloor(1);
                    e1.openDoors();
                    e1.setMovingDirection("stopped"); 
                    departPersons(1, 1);
                    boardPersons(1, 1);
                }
                else if (e1.getCurrentFloor() == 2 || e1.getCurrentFloor() == 3 || e1.getCurrentFloor() == 4 || e1.getCurrentFloor() == 5)
                {
                    if (e1.getPanel().Location.Y < 339)
                    {
                        if (e1.getDoorStatus().Equals("open"))
                        {
                            e1.closeDoors();
                        }
                        else if (e1.getDoorStatus().Equals("closed"))
                        {
                            e1.moveLift("down");
                            e1.setMovingDirection("down"); 
                        }
                    }
                    else
                    {
                        e1.removeCommand("floor1");
                        turnInternalLightOff(INTERNAL_LIFT1_FL1);
                        e1.setCurrentFloor(1);
                        e1.openDoors();
                        e1.setMovingDirection("stopped"); 
                        departPersons(1, 1);
                        boardPersons(1, 1);
                    }
                }
            }



            /* floor2 floor2 floor2 floor2 floor2 floor2 floor2 floor2 floor2 */
            if (e1.getNextCommand().Equals("floor2"))
            {
                if (e1.getCurrentFloor() == 1)
                {
                    if (e1.getPanel().Location.Y > 252)
                    {
                        if (e1.getDoorStatus().Equals("open"))
                        {
                            e1.closeDoors();
                        }
                        else if (e1.getDoorStatus().Equals("closed"))
                        {
                            e1.moveLift("up");
                            e1.setMovingDirection("up"); 
                        }
                    }
                    else
                    {
                        e1.removeCommand("floor2");
                        turnInternalLightOff(INTERNAL_LIFT1_FL2);
                        e1.setCurrentFloor(2);
                        e1.openDoors();
                        e1.setMovingDirection("stopped"); 
                        departPersons(2, 1);
                        boardPersons(2, 1);
                    }
                }
                else if (e1.getCurrentFloor() == 2)
                {
                    e1.removeCommand("floor2");
                    turnInternalLightOff(INTERNAL_LIFT1_FL2);
                    e1.setCurrentFloor(2);
                    e1.openDoors();
                    e1.setMovingDirection("stopped"); 
                    departPersons(2, 1);
                    boardPersons(2, 1);
                }
                else if (e1.getCurrentFloor() == 3 || e1.getCurrentFloor() == 4 || e1.getCurrentFloor() == 5)
                {
                    if (e1.getPanel().Location.Y < 252)
                    {
                        if (e1.getDoorStatus().Equals("open"))
                        {
                            e1.closeDoors();
                        }
                        else if (e1.getDoorStatus().Equals("closed"))
                        {
                            e1.moveLift("down");
                            e1.setMovingDirection("down"); 
                        }
                    }
                    else
                    {
                        e1.removeCommand("floor2");
                        turnInternalLightOff(INTERNAL_LIFT1_FL2);
                        e1.setCurrentFloor(2);
                        e1.openDoors();
                        e1.setMovingDirection("stopped");
                        departPersons(2, 1);
                        boardPersons(2, 1);
                    }
                }
            }



            /* floor3 floor3 floor3 floor3 floor3 floor3 floor3 floor3 floor3 */
            if (e1.getNextCommand().Equals("floor3"))
            {
                if (e1.getCurrentFloor() == 1 || e1.getCurrentFloor() == 2)
                {
                    if (e1.getPanel().Location.Y > 171)
                    {
                        if (e1.getDoorStatus().Equals("open"))
                        {
                            e1.closeDoors();
                        }
                        else if (e1.getDoorStatus().Equals("closed"))
                        {
                            e1.moveLift("up");
                            e1.setMovingDirection("up"); 
                        }
                    }
                    else
                    {
                        e1.removeCommand("floor3");
                        turnInternalLightOff(INTERNAL_LIFT1_FL3);
                        e1.setCurrentFloor(3);
                        e1.openDoors();
                        e1.setMovingDirection("stopped"); 
                        departPersons(3, 1);
                        boardPersons(3, 1);
                    }
                }
                else if (e1.getCurrentFloor() == 3)
                {
                    e1.removeCommand("floor3");
                    turnInternalLightOff(INTERNAL_LIFT1_FL3);
                    e1.setCurrentFloor(3);
                    e1.openDoors();
                    e1.setMovingDirection("stopped"); 
                    departPersons(3, 1);
                    boardPersons(3, 1);
                }
                else if (e1.getCurrentFloor() == 4 || e1.getCurrentFloor() == 5)
                {
                    if (e1.getPanel().Location.Y < 171)
                    {
                        if (e1.getDoorStatus().Equals("open"))
                        {
                            e1.closeDoors();
                        }
                        else if (e1.getDoorStatus().Equals("closed"))
                        {
                            e1.moveLift("down");
                            e1.setMovingDirection("down"); 
                        }
                    }
                    else
                    {
                        e1.removeCommand("floor3");
                        turnInternalLightOff(INTERNAL_LIFT1_FL3);
                        e1.setCurrentFloor(3);
                        e1.setMovingDirection("stopped"); 
                        e1.openDoors();
                        departPersons(3, 1);
                        boardPersons(3, 1);
                    }
                }
            }




            /* floor4 floor4 floor4 floor4 floor4 floor4 floor4 floor4 floor4 floor4 */
            if (e1.getNextCommand().Equals("floor4"))
            {
                if (e1.getCurrentFloor() == 1 || e1.getCurrentFloor() == 2 || e1.getCurrentFloor() == 3)
                {
                    if (e1.getPanel().Location.Y > 88)
                    {
                        if (e1.getDoorStatus().Equals("open"))
                        {
                            e1.closeDoors();
                        }
                        else if (e1.getDoorStatus().Equals("closed"))
                        {
                            e1.moveLift("up");
                            e1.setMovingDirection("up"); 
                        }
                    }
                    else
                    {
                        e1.removeCommand("floor4");
                        turnInternalLightOff(INTERNAL_LIFT1_FL4);
                        e1.setCurrentFloor(4);
                        e1.openDoors();
                        e1.setMovingDirection("stopped"); 
                        departPersons(4, 1);
                        boardPersons(4, 1);
                    }
                }
                else if (e1.getCurrentFloor() == 4)
                {
                    e1.removeCommand("floor4");
                    turnInternalLightOff(INTERNAL_LIFT1_FL4);
                    e1.setCurrentFloor(4);
                    e1.openDoors();
                    e1.setMovingDirection("stopped"); 
                    departPersons(4, 1);
                    boardPersons(4, 1);
                }
                else if (e1.getCurrentFloor() == 5)
                {
                    if (e1.getPanel().Location.Y < 88)
                    {
                        if (e1.getDoorStatus().Equals("open"))
                        {
                            e1.closeDoors();
                        }
                        else if (e1.getDoorStatus().Equals("closed"))
                        {
                            e1.moveLift("down");
                            e1.setMovingDirection("down"); 
                        }
                    }
                    else
                    {
                        e1.removeCommand("floor4");
                        turnInternalLightOff(INTERNAL_LIFT1_FL4);
                        e1.setCurrentFloor(4);
                        e1.openDoors();
                        e1.setMovingDirection("stopped"); 
                        departPersons(4, 1);
                        boardPersons(4, 1);
                    }
                }
            }




            /* floor5 floor5 floor5 floor5 floor5 floor5 floor5 floor5 floor5 floor5 */
            if (e1.getNextCommand().Equals("floor5"))
            {
                if (e1.getCurrentFloor() == 1 || e1.getCurrentFloor() == 2 || e1.getCurrentFloor() == 3 || e1.getCurrentFloor() == 4)
                {
                    if (e1.getPanel().Location.Y > 1)
                    {
                        if (e1.getDoorStatus().Equals("open"))
                        {
                            e1.closeDoors();
                        }
                        else if (e1.getDoorStatus().Equals("closed"))
                        {
                            e1.moveLift("up");
                            e1.setMovingDirection("up"); 
                        }
                    }
                    else
                    {
                        e1.removeCommand("floor5");
                        turnInternalLightOff(INTERNAL_LIFT1_FL5);
                        e1.setCurrentFloor(5);
                        e1.openDoors();
                        e1.setMovingDirection("stopped"); 
                        departPersons(5, 1);
                        boardPersons(5, 1);
                    }
                }
                else if (e1.getCurrentFloor() == 5)
                {
                    e1.removeCommand("floor5");
                    turnInternalLightOff(INTERNAL_LIFT1_FL5);
                    e1.setCurrentFloor(5);
                    e1.openDoors();
                    e1.setMovingDirection("stopped"); 
                    departPersons(5, 1);
                    boardPersons(5, 1);
                }
            }


        }
        private void e2scheduler_Tick(object sender, EventArgs e)
        {
            /* up1 up1 up1 up1 up1 up1 up1 up1 up1 up1 up1 up1 */
            if (e2.getNextCommand().Equals("up1"))
            {
                if (e2.getCurrentFloor() == 1)
                {
                    e2.removeCommand("up1");
                    turnLightOff(FIRST_FLOOR_UP_BTTN);
                    e2.setCurrentFloor(1);
                    e2.openDoors();
                    e2.setMovingDirection("stopped"); 
                    departPersons(1, 2);
                    boardPersons(1, 2);
                }
                else if (e2.getCurrentFloor() == 2 || e2.getCurrentFloor() == 3 || e2.getCurrentFloor() == 4 || e2.getCurrentFloor() == 5)
                {
                    if (e2.getPanel().Location.Y < 339)
                    {
                        if (e2.getDoorStatus().Equals("open"))
                        {
                            e2.closeDoors();
                        }
                        else if (e2.getDoorStatus().Equals("closed"))
                        {
                            e2.moveLift("down");
                            e2.setMovingDirection("down"); 
                        }
                    }
                    else
                    {
                        e2.removeCommand("up1");
                        turnLightOff(FIRST_FLOOR_UP_BTTN);
                        e2.setCurrentFloor(1);
                        e2.openDoors();
                        e2.setMovingDirection("stopped"); 
                        departPersons(1, 2);
                        boardPersons(1, 2);
                    }
                }
            }


            /* down2 down2 down2 down2 down2 down2 down2 down2 */
            if (e2.getNextCommand().Equals("down2"))
            {
                if (e2.getCurrentFloor() == 1)
                {
                    if (e2.getPanel().Location.Y > 252)
                    {
                        if (e2.getDoorStatus().Equals("open"))
                        {
                            e2.closeDoors();
                        }
                        else if (e2.getDoorStatus().Equals("closed"))
                        {
                            e2.moveLift("up");
                            e2.setMovingDirection("up"); 
                        }
                    }
                    else
                    {
                        e2.removeCommand("down2");
                        turnLightOff(SECOND_FLOOR_DOWN_BTTN);
                        e2.setCurrentFloor(2);
                        e2.openDoors();
                        e2.setMovingDirection("stopped"); 
                        departPersons(2, 2);
                        boardPersons(2, 2);
                    }
                }
                else if (e2.getCurrentFloor() == 2)
                {
                    e2.removeCommand("down2");
                    turnLightOff(SECOND_FLOOR_DOWN_BTTN);
                    e2.setCurrentFloor(2);
                    e2.openDoors();
                    e2.setMovingDirection("stopped"); 
                    departPersons(2, 2);
                    boardPersons(2, 2);
                }
                else if (e2.getCurrentFloor() == 3 || e2.getCurrentFloor() == 4 || e2.getCurrentFloor() == 5)
                {
                    if (e2.getPanel().Location.Y < 252)
                    {
                        if (e2.getDoorStatus().Equals("open"))
                        {
                            e2.closeDoors();
                        }
                        else if (e2.getDoorStatus().Equals("closed"))
                        {
                            e2.moveLift("down");
                            e2.setMovingDirection("down"); 
                        }
                    }
                    else
                    {
                        e2.removeCommand("down2");
                        turnLightOff(SECOND_FLOOR_DOWN_BTTN);
                        e2.setCurrentFloor(2);
                        e2.openDoors();
                        e2.setMovingDirection("stopped"); 
                        departPersons(2, 2);
                        boardPersons(2, 2);
                    }
                }
            }


            /* up2 up2 up2 up2 up2 up2 up2 up2 up2 up2 up2 up2 */
            if (e2.getNextCommand().Equals("up2"))
            {
                if (e2.getCurrentFloor() == 1)
                {
                    if (e2.getPanel().Location.Y > 252)
                    {
                        if (e2.getDoorStatus().Equals("open"))
                        {
                            e2.closeDoors();
                        }
                        else if (e2.getDoorStatus().Equals("closed"))
                        {
                            e2.moveLift("up");
                            e2.setMovingDirection("up"); 
                        }
                    }
                    else
                    {
                        e2.removeCommand("up2");
                        turnLightOff(SECOND_FLOOR_UP_BTTN);
                        e2.setCurrentFloor(2);
                        e2.openDoors();
                        e2.setMovingDirection("stopped"); 
                        departPersons(2, 2);
                        boardPersons(2, 2);
                    }
                }
                else if (e2.getCurrentFloor() == 2)
                {
                    e2.removeCommand("up2");
                    turnLightOff(SECOND_FLOOR_UP_BTTN);
                    e2.setCurrentFloor(2);
                    e2.openDoors();
                    e2.setMovingDirection("stopped"); 
                    departPersons(2, 2);
                    boardPersons(2, 2);
                }
                else if (e2.getCurrentFloor() == 3 || e2.getCurrentFloor() == 4 || e2.getCurrentFloor() == 5)
                {
                    if (e2.getPanel().Location.Y < 252)
                    {
                        if (e2.getDoorStatus().Equals("open"))
                        {
                            e2.closeDoors();
                        }
                        else if (e2.getDoorStatus().Equals("closed"))
                        {
                            e2.moveLift("down");
                            e2.setMovingDirection("down"); 
                        }
                    }
                    else
                    {
                        e2.removeCommand("up2");
                        turnLightOff(SECOND_FLOOR_UP_BTTN);
                        e2.setCurrentFloor(2);
                        e2.openDoors();
                        e2.setMovingDirection("stopped"); 
                        departPersons(2, 2);
                        boardPersons(2, 2);
                    }
                }
            }





            /* down3 down3 down3 down3 down3 down3 down3 down3 */
            if (e2.getNextCommand().Equals("down3"))
            {
                if (e2.getCurrentFloor() == 1 || e2.getCurrentFloor() == 2)
                {
                    if (e2.getPanel().Location.Y > 171)
                    {
                        if (e2.getDoorStatus().Equals("open"))
                        {
                            e2.closeDoors();
                        }
                        else if (e2.getDoorStatus().Equals("closed"))
                        {
                            e2.moveLift("up");
                            e2.setMovingDirection("up"); 
                        }
                    }
                    else
                    {
                        e2.removeCommand("down3");
                        turnLightOff(THIRD_FLOOR_DOWN_BTTN);
                        e2.setCurrentFloor(3);
                        e2.openDoors();
                        e2.setMovingDirection("stopped"); 
                        departPersons(3, 2);
                        boardPersons(3, 2);
                    }
                }
                else if (e2.getCurrentFloor() == 3)
                {
                    e2.removeCommand("down3");
                    turnLightOff(THIRD_FLOOR_DOWN_BTTN);
                    e2.setCurrentFloor(3);
                    e2.openDoors();
                    e2.setMovingDirection("stopped"); 
                    departPersons(3, 2);
                    boardPersons(3, 2);
                }
                else if (e2.getCurrentFloor() == 4 || e2.getCurrentFloor() == 5)
                {
                    if (e2.getPanel().Location.Y < 171)
                    {
                        if (e2.getDoorStatus().Equals("open"))
                        {
                            e2.closeDoors();
                        }
                        else if (e2.getDoorStatus().Equals("closed"))
                        {
                            e2.moveLift("down");
                            e2.setMovingDirection("down"); 
                        }
                    }
                    else
                    {
                        e2.removeCommand("down3");
                        turnLightOff(THIRD_FLOOR_DOWN_BTTN);
                        e2.setCurrentFloor(3);
                        e2.openDoors();
                        e2.setMovingDirection("stopped"); 
                        departPersons(3, 2);
                        boardPersons(3, 2);
                    }
                }
            }



            /* up3 up3 up3 up3 up3 up3 up3 up3 up3 up3 up3 up3 up3 */
            if (e2.getNextCommand().Equals("up3"))
            {
                if (e2.getCurrentFloor() == 1 || e2.getCurrentFloor() == 2)
                {
                    if (e2.getPanel().Location.Y > 171)
                    {
                        if (e2.getDoorStatus().Equals("open"))
                        {
                            e2.closeDoors();
                        }
                        else if (e2.getDoorStatus().Equals("closed"))
                        {
                            e2.moveLift("up");
                            e2.setMovingDirection("up");
                        }
                    }
                    else
                    {
                        e2.removeCommand("up3");
                        turnLightOff(THIRD_FLOOR_UP_BTTN);
                        e2.setCurrentFloor(3);
                        e2.openDoors();
                        e2.setMovingDirection("stopped"); 
                        departPersons(3, 2);
                        boardPersons(3, 2);
                    }
                }
                else if (e3.getCurrentFloor() == 3)
                {
                    e2.removeCommand("up3");
                    turnLightOff(THIRD_FLOOR_UP_BTTN);
                    e2.setCurrentFloor(3);
                    e2.openDoors();
                    e2.setMovingDirection("stopped"); 
                    departPersons(3, 2);
                    boardPersons(3, 2);
                }
                else if (e2.getCurrentFloor() == 4 || e2.getCurrentFloor() == 5)
                {
                    if (e2.getPanel().Location.Y < 171)
                    {
                        if (e2.getDoorStatus().Equals("open"))
                        {
                            e2.closeDoors();
                        }
                        else if (e2.getDoorStatus().Equals("closed"))
                        {
                            e2.moveLift("down");
                            e2.setMovingDirection("down"); 
                        }
                    }
                    else
                    {
                        e2.removeCommand("up3");
                        turnLightOff(THIRD_FLOOR_UP_BTTN);
                        e2.setCurrentFloor(3);
                        e2.openDoors();
                        e2.setMovingDirection("stopped"); 
                        departPersons(3, 2);
                        boardPersons(3, 2);
                    }
                }
            }


            /* down4 down4 down4 down4 down4 down4 down4 down4 */
            if (e2.getNextCommand().Equals("down4"))
            {
                if (e2.getCurrentFloor() == 1 || e2.getCurrentFloor() == 2 || e2.getCurrentFloor() == 3)
                {
                    if (e2.getPanel().Location.Y > 88)
                    {
                        if (e2.getDoorStatus().Equals("open"))
                        {
                            e2.closeDoors();
                        }
                        else if (e2.getDoorStatus().Equals("closed"))
                        {
                            e2.moveLift("up");
                            e2.setMovingDirection("up"); 
                        }
                    }
                    else
                    {
                        e2.removeCommand("down4");
                        turnLightOff(FOURTH_FLOOR_DOWN_BTTN);
                        e2.setCurrentFloor(4);
                        e2.openDoors();
                        e2.setMovingDirection("stopped"); 
                        departPersons(4, 2);
                        boardPersons(4, 2);
                    }
                }
                else if (e2.getCurrentFloor() == 4)
                {
                    e2.removeCommand("down4");
                    turnLightOff(FOURTH_FLOOR_DOWN_BTTN);
                    e2.setCurrentFloor(4);
                    e2.openDoors();
                    e2.setMovingDirection("stopped"); 
                    departPersons(4, 2);
                    boardPersons(4, 2);
                }
                else if (e2.getCurrentFloor() == 5)
                {
                    if (e2.getPanel().Location.Y < 88)
                    {
                        if (e2.getDoorStatus().Equals("open"))
                        {
                            e2.closeDoors();
                        }
                        else if (e2.getDoorStatus().Equals("closed"))
                        {
                            e2.moveLift("down");
                            e2.setMovingDirection("down"); 
                        }
                    }
                    else
                    {
                        e2.removeCommand("down4");
                        turnLightOff(FOURTH_FLOOR_DOWN_BTTN);
                        e2.setCurrentFloor(4);
                        e2.openDoors();
                        e2.setMovingDirection("stopped"); 
                        departPersons(4, 2);
                        boardPersons(4, 2);
                    }
                }
            }





            /* up4 up4 up4 up4 up4 up4 up4 up4 up4 up4 up4 up4 */
            if (e2.getNextCommand().Equals("up4"))
            {
                if (e2.getCurrentFloor() == 1 || e2.getCurrentFloor() == 2 || e2.getCurrentFloor() == 3)
                {
                    if (e2.getPanel().Location.Y > 88)
                    {
                        if (e2.getDoorStatus().Equals("open"))
                        {
                            e2.closeDoors();
                        }
                        else if (e2.getDoorStatus().Equals("closed"))
                        {
                            e2.moveLift("up");
                            e2.setMovingDirection("up"); 
                        }
                    }
                    else
                    {
                        e2.removeCommand("up4");
                        turnLightOff(FOURTH_FLOOR_UP_BTTN);
                        e2.setCurrentFloor(4);
                        e2.openDoors();
                        e2.setMovingDirection("stopped"); 
                        departPersons(4, 2);
                        boardPersons(4, 2);
                    }
                }
                else if (e2.getCurrentFloor() == 4)
                {
                    e2.removeCommand("up4");
                    turnLightOff(FOURTH_FLOOR_UP_BTTN);
                    e2.setCurrentFloor(4);
                    e2.openDoors();
                    e2.setMovingDirection("stopped"); 
                    departPersons(4, 2);
                    boardPersons(4, 2);
                }
                else if (e2.getCurrentFloor() == 5)
                {
                    if (e2.getPanel().Location.Y < 88)
                    {
                        if (e2.getDoorStatus().Equals("open"))
                        {
                            e2.closeDoors();
                        }
                        else if (e2.getDoorStatus().Equals("closed"))
                        {
                            e2.moveLift("down");
                            e2.setMovingDirection("down"); 
                        }
                    }
                    else
                    {
                        e2.removeCommand("up4");
                        turnLightOff(FOURTH_FLOOR_UP_BTTN);
                        e2.setCurrentFloor(4);
                        e2.openDoors();
                        e2.setMovingDirection("stopped"); 
                        departPersons(4, 2);
                        boardPersons(4, 2);
                    }
                }
            }


            /* down5 down5 down5 down5 down5 down5 down5 down5 down5 */
            if (e2.getNextCommand().Equals("down5"))
            {
                if (e2.getCurrentFloor() == 1 || e2.getCurrentFloor() == 2 || e2.getCurrentFloor() == 3 || e2.getCurrentFloor() == 4)
                {
                    if (e2.getPanel().Location.Y > 1)
                    {
                        if (e2.getDoorStatus().Equals("open"))
                        {
                            e2.closeDoors();
                        }
                        else if (e2.getDoorStatus().Equals("closed"))
                        {
                            e2.moveLift("up");
                            e2.setMovingDirection("up"); 
                        }
                    }
                    else
                    {
                        e2.removeCommand("down5");
                        turnLightOff(FIFTH_FLOOR_DOWN_BTTN);
                        e2.setCurrentFloor(5);
                        e2.openDoors();
                        e2.setMovingDirection("stopped"); 
                        departPersons(5, 2);
                        boardPersons(5, 2);
                    }
                }
                else if (e2.getCurrentFloor() == 5)
                {
                    e2.removeCommand("down5");
                    turnLightOff(FIFTH_FLOOR_DOWN_BTTN);
                    e2.setCurrentFloor(5);
                    e2.openDoors();
                    e2.setMovingDirection("stopped"); 
                    departPersons(5, 2);
                    boardPersons(5, 2);
                }
            }




            /* floor1 floor1 floor1 floor1 floor1 floor1 floor1 floor1 floor1 */
            if (e2.getNextCommand().Equals("floor1"))
            {
                if (e2.getCurrentFloor() == 1)
                {
                    e2.removeCommand("floor1");
                    turnInternalLightOff(INTERNAL_LIFT2_FL1);
                    e2.setCurrentFloor(1);
                    e2.openDoors();
                    e2.setMovingDirection("stopped"); 
                    departPersons(1, 2);
                    boardPersons(1, 2);
                }
                else if (e2.getCurrentFloor() == 2 || e2.getCurrentFloor() == 3 || e2.getCurrentFloor() == 4 || e2.getCurrentFloor() == 5)
                {
                    if (e2.getPanel().Location.Y < 339)
                    {
                        if (e2.getDoorStatus().Equals("open"))
                        {
                            e2.closeDoors();
                        }
                        else if (e2.getDoorStatus().Equals("closed"))
                        {
                            e2.moveLift("down");
                            e2.setMovingDirection("down"); 
                        }
                    }
                    else
                    {
                        e2.removeCommand("floor1");
                        turnInternalLightOff(INTERNAL_LIFT2_FL1);
                        e2.setCurrentFloor(1);
                        e2.openDoors();
                        e2.setMovingDirection("stopped"); 
                        departPersons(1, 2);
                        boardPersons(1, 2);
                    }
                }
            }




            /* floor2 floor2 floor2 floor2 floor2 floor2 floor2 floor2 floor2 */
            if (e2.getNextCommand().Equals("floor2"))
            {
                if (e2.getCurrentFloor() == 1)
                {
                    if (e2.getPanel().Location.Y > 252)
                    {
                        if (e2.getDoorStatus().Equals("open"))
                        {
                            e2.closeDoors();
                        }
                        else if (e2.getDoorStatus().Equals("closed"))
                        {
                            e2.moveLift("up");
                            e2.setMovingDirection("up"); 
                        }
                    }
                    else
                    {
                        e2.removeCommand("floor2");
                        turnInternalLightOff(INTERNAL_LIFT2_FL2);
                        e2.setCurrentFloor(2);
                        e2.openDoors();
                        e2.setMovingDirection("stopped"); 
                        departPersons(2, 2);
                        boardPersons(2, 2);
                    }
                }
                else if (e2.getCurrentFloor() == 2)
                {
                    e2.removeCommand("floor2");
                    turnInternalLightOff(INTERNAL_LIFT2_FL2);
                    e2.setCurrentFloor(2);
                    e2.openDoors();
                    e2.setMovingDirection("stopped"); 
                    departPersons(2, 2);
                    boardPersons(2, 2);
                }
                else if (e2.getCurrentFloor() == 3 || e2.getCurrentFloor() == 4 || e2.getCurrentFloor() == 5)
                {
                    if (e2.getPanel().Location.Y < 252)
                    {
                        if (e2.getDoorStatus().Equals("open"))
                        {
                            e2.closeDoors();
                        }
                        else if (e2.getDoorStatus().Equals("closed"))
                        {
                            e2.moveLift("down");
                            e2.setMovingDirection("down"); 
                        }
                    }
                    else
                    {
                        e2.removeCommand("floor2");
                        turnInternalLightOff(INTERNAL_LIFT2_FL2);
                        e2.setCurrentFloor(2);
                        e2.openDoors();
                        e2.setMovingDirection("stopped");
                        departPersons(2, 2);
                        boardPersons(2, 2);
                    }
                }
            }



            /* floor3 floor3 floor3 floor3 floor3 floor3 floor3 floor3 floor3 */
            if (e2.getNextCommand().Equals("floor3"))
            {
                if (e2.getCurrentFloor() == 1 || e2.getCurrentFloor() == 2)
                {
                    if (e2.getPanel().Location.Y > 171)
                    {
                        if (e2.getDoorStatus().Equals("open"))
                        {
                            e2.closeDoors();
                        }
                        else if (e2.getDoorStatus().Equals("closed"))
                        {
                            e2.moveLift("up");
                            e2.setMovingDirection("up");
                        }
                    }
                    else
                    {
                        e2.removeCommand("floor3");
                        turnInternalLightOff(INTERNAL_LIFT2_FL3);
                        e2.setCurrentFloor(3);
                        e2.openDoors();
                        e2.setMovingDirection("stopped"); 
                        departPersons(3, 2);
                        boardPersons(3, 2);
                    }
                }
                else if (e2.getCurrentFloor() == 3)
                {
                    e2.removeCommand("floor3");
                    turnInternalLightOff(INTERNAL_LIFT2_FL3);
                    e2.setCurrentFloor(3);
                    e2.openDoors();
                    e2.setMovingDirection("stopped"); 
                    departPersons(3, 2);
                    boardPersons(3, 2);
                }
                else if (e2.getCurrentFloor() == 4 || e2.getCurrentFloor() == 5)
                {
                    if (e2.getPanel().Location.Y < 171)
                    {
                        if (e2.getDoorStatus().Equals("open"))
                        {
                            e2.closeDoors();
                        }
                        else if (e2.getDoorStatus().Equals("closed"))
                        {
                            e2.moveLift("down");
                            e2.setMovingDirection("down"); 
                        }
                    }
                    else
                    {
                        e2.removeCommand("floor3");
                        turnInternalLightOff(INTERNAL_LIFT2_FL3);
                        e2.setCurrentFloor(3);
                        e2.openDoors();
                        e2.setMovingDirection("stopped"); 
                        departPersons(3, 2);
                        boardPersons(3, 2);
                    }
                }
            }




            /* floor4 floor4 floor4 floor4 floor4 floor4 floor4 floor4 floor4 floor4 */
            if (e2.getNextCommand().Equals("floor4"))
            {
                if (e2.getCurrentFloor() == 1 || e2.getCurrentFloor() == 2 || e2.getCurrentFloor() == 3)
                {
                    if (e2.getPanel().Location.Y > 88)
                    {
                        if (e2.getDoorStatus().Equals("open"))
                        {
                            e2.closeDoors();
                        }
                        else if (e2.getDoorStatus().Equals("closed"))
                        {
                            e2.moveLift("up");
                            e2.setMovingDirection("up"); 
                        }
                    }
                    else
                    {
                        e2.removeCommand("floor4");
                        turnInternalLightOff(INTERNAL_LIFT2_FL4);
                        e2.setCurrentFloor(4);
                        e2.openDoors();
                        e2.setMovingDirection("stopped"); 
                        departPersons(4, 2);
                        boardPersons(4, 2);
                    }
                }
                else if (e2.getCurrentFloor() == 4)
                {
                    e2.removeCommand("floor4");
                    turnInternalLightOff(INTERNAL_LIFT2_FL4);
                    e2.setCurrentFloor(4);
                    e2.openDoors();
                    e2.setMovingDirection("stopped"); 
                    departPersons(4, 2);
                    boardPersons(4, 2);
                }
                else if (e2.getCurrentFloor() == 5)
                {
                    if (e2.getPanel().Location.Y < 88)
                    {
                        if (e2.getDoorStatus().Equals("open"))
                        {
                            e2.closeDoors();
                        }
                        else if (e2.getDoorStatus().Equals("closed"))
                        {
                            e2.moveLift("down");
                            e2.setMovingDirection("down"); 
                        }
                    }
                    else
                    {
                        e2.removeCommand("floor4");
                        turnInternalLightOff(INTERNAL_LIFT2_FL4);
                        e2.setCurrentFloor(4);
                        e2.openDoors();
                        e2.setMovingDirection("stopped"); 
                        departPersons(4, 2);
                        boardPersons(4, 2);
                    }
                }
            }



            /* floor5 floor5 floor5 floor5 floor5 floor5 floor5 floor5 floor5 floor5 */
            if (e2.getNextCommand().Equals("floor5"))
            {
                if (e2.getCurrentFloor() == 1 || e2.getCurrentFloor() == 2 || e2.getCurrentFloor() == 3 || e2.getCurrentFloor() == 4)
                {
                    if (e2.getPanel().Location.Y > 1)
                    {
                        if (e2.getDoorStatus().Equals("open"))
                        {
                            e2.closeDoors();
                        }
                        else if (e2.getDoorStatus().Equals("closed"))
                        {
                            e2.moveLift("up");
                            e2.setMovingDirection("up"); 
                        }
                    }
                    else
                    {
                        e2.removeCommand("floor5");
                        turnInternalLightOff(INTERNAL_LIFT2_FL5);
                        e2.setCurrentFloor(5);
                        e2.openDoors();
                        e2.setMovingDirection("stopped"); 
                        departPersons(5, 2);
                        boardPersons(5, 2);
                    }
                }
                else if (e2.getCurrentFloor() == 5)
                {
                    e2.removeCommand("floor5");
                    turnInternalLightOff(INTERNAL_LIFT2_FL5);
                    e2.setCurrentFloor(5);
                    e2.openDoors();
                    e2.setMovingDirection("stopped");
                    departPersons(5, 2);
                    boardPersons(5, 2);
                }
            }

        }
        private void e3scheduler_Tick(object sender, EventArgs e)
        {
            /* up1 up1 up1 up1 up1 up1 up1 up1 up1 up1 up1 up1 */
            if (e3.getNextCommand().Equals("up1"))
            {
                if (e3.getCurrentFloor() == 1)
                {
                    e3.removeCommand("up1");
                    turnLightOff(FIRST_FLOOR_UP_BTTN);
                    e3.setCurrentFloor(1);
                    e3.openDoors();
                    e3.setMovingDirection("stopped"); 
                    departPersons(1, 3);
                    boardPersons(1, 3);
                }
                else if (e3.getCurrentFloor() == 2 || e3.getCurrentFloor() == 3 || e3.getCurrentFloor() == 4 || e3.getCurrentFloor() == 5)
                {
                    if (e3.getPanel().Location.Y < 339)
                    {
                        if (e3.getDoorStatus().Equals("open"))
                        {
                            e3.closeDoors();
                        }
                        else if (e3.getDoorStatus().Equals("closed"))
                        {
                            e3.moveLift("down");
                            e3.setMovingDirection("down"); 
                        }
                    }
                    else
                    {
                        e3.removeCommand("up1");
                        turnLightOff(FIRST_FLOOR_UP_BTTN);
                        e3.setCurrentFloor(1);
                        e3.openDoors();
                        e3.setMovingDirection("stopped"); 
                        departPersons(1, 3);
                        boardPersons(1, 3);
                    }
                }
            }



            /* down2 down2 down2 down2 down2 down2 down2 down2 */
            if (e3.getNextCommand().Equals("down2"))
            {
                if (e3.getCurrentFloor() == 1)
                {
                    if (e3.getPanel().Location.Y > 252)
                    {
                        if (e3.getDoorStatus().Equals("open"))
                        {
                            e3.closeDoors();
                        }
                        else if (e3.getDoorStatus().Equals("closed"))
                        {
                            e3.moveLift("up");
                            e3.setMovingDirection("up"); 
                        }
                    }
                    else
                    {
                        e3.removeCommand("down2");
                        turnLightOff(SECOND_FLOOR_DOWN_BTTN);
                        e3.setCurrentFloor(2);
                        e3.openDoors();
                        e3.setMovingDirection("stopped"); 
                        departPersons(2, 3);
                        boardPersons(2, 3);
                    }
                }
                else if (e3.getCurrentFloor() == 2)
                {
                    e3.removeCommand("down2");
                    turnLightOff(SECOND_FLOOR_DOWN_BTTN);
                    e3.setCurrentFloor(2);
                    e3.openDoors();
                    e3.setMovingDirection("stopped"); 
                    departPersons(2, 3);
                    boardPersons(2, 3);
                }
                else if (e3.getCurrentFloor() == 3 || e3.getCurrentFloor() == 4 || e3.getCurrentFloor() == 5)
                {
                    if (e3.getPanel().Location.Y < 252)
                    {
                        if (e3.getDoorStatus().Equals("open"))
                        {
                            e3.closeDoors();
                        }
                        else if (e3.getDoorStatus().Equals("closed"))
                        {
                            e3.moveLift("down");
                            e3.setMovingDirection("down"); 
                        }
                    }
                    else
                    {
                        e3.removeCommand("down2");
                        turnLightOff(SECOND_FLOOR_DOWN_BTTN);
                        e3.setCurrentFloor(2);
                        e3.openDoors();
                        e3.setMovingDirection("stopped"); 
                        departPersons(2, 3);
                        boardPersons(2, 3);
                    }
                }
            }



            /* up2 up2 up2 up2 up2 up2 up2 up2 up2 up2 up2 up2 */
            if (e3.getNextCommand().Equals("up2"))
            {
                if (e3.getCurrentFloor() == 1)
                {
                    if (e3.getPanel().Location.Y > 252)
                    {
                        if (e3.getDoorStatus().Equals("open"))
                        {
                            e3.closeDoors();
                        }
                        else if (e3.getDoorStatus().Equals("closed"))
                        {
                            e3.moveLift("up");
                            e3.setMovingDirection("up"); 
                        }
                    }
                    else
                    {
                        e3.removeCommand("up2");
                        turnLightOff(SECOND_FLOOR_UP_BTTN);
                        e3.setCurrentFloor(2);
                        e3.openDoors();
                        e3.setMovingDirection("stopped"); 
                        departPersons(2, 3);
                        boardPersons(2, 3);
                    }
                }
                else if (e3.getCurrentFloor() == 2)
                {
                    e3.removeCommand("up2");
                    turnLightOff(SECOND_FLOOR_UP_BTTN);
                    e3.setCurrentFloor(2);
                    e3.openDoors();
                    e3.setMovingDirection("stopped"); 
                    departPersons(2, 3);
                    boardPersons(2, 3);
                }
                else if (e3.getCurrentFloor() == 3 || e3.getCurrentFloor() == 4 || e3.getCurrentFloor() == 5)
                {
                    if (e3.getPanel().Location.Y < 252)
                    {
                        if (e3.getDoorStatus().Equals("open"))
                        {
                            e3.closeDoors();
                        }
                        else if (e3.getDoorStatus().Equals("closed"))
                        {
                            e3.moveLift("down");
                            e3.setMovingDirection("down"); 
                        }
                    }
                    else
                    {
                        e3.removeCommand("up2");
                        turnLightOff(SECOND_FLOOR_UP_BTTN);
                        e3.setCurrentFloor(2);
                        e3.openDoors();
                        e3.setMovingDirection("stopped"); 
                        departPersons(2, 3);
                        boardPersons(2, 3);
                    }
                }
            }





            /* down3 down3 down3 down3 down3 down3 down3 down3 */
            if (e3.getNextCommand().Equals("down3"))
            {
                if (e3.getCurrentFloor() == 1 || e3.getCurrentFloor() == 2)
                {
                    if (e3.getPanel().Location.Y > 171)
                    {
                        if (e3.getDoorStatus().Equals("open"))
                        {
                            e3.closeDoors();
                        }
                        else if (e3.getDoorStatus().Equals("closed"))
                        {
                            e3.moveLift("up");
                            e3.setMovingDirection("up"); 
                        }
                    }
                    else
                    {
                        e3.removeCommand("down3");
                        turnLightOff(THIRD_FLOOR_DOWN_BTTN);
                        e3.setCurrentFloor(3);
                        e3.openDoors();
                        e3.setMovingDirection("stopped"); 
                        departPersons(3, 3);
                        boardPersons(3, 3);
                    }
                }
                else if (e3.getCurrentFloor() == 3)
                {
                    e3.removeCommand("down3");
                    turnLightOff(THIRD_FLOOR_DOWN_BTTN);
                    e3.setCurrentFloor(3);
                    e3.openDoors();
                    e3.setMovingDirection("stopped"); 
                    departPersons(3, 3);
                    boardPersons(3, 3);
                }
                else if (e3.getCurrentFloor() == 4 || e3.getCurrentFloor() == 5)
                {
                    if (e3.getPanel().Location.Y < 171)
                    {
                        if (e3.getDoorStatus().Equals("open"))
                        {
                            e3.closeDoors();
                        }
                        else if (e3.getDoorStatus().Equals("closed"))
                        {
                            e3.moveLift("down");
                            e3.setMovingDirection("down"); 
                        }
                    }
                    else
                    {
                        e3.removeCommand("down3");
                        turnLightOff(THIRD_FLOOR_DOWN_BTTN);
                        e3.setCurrentFloor(3);
                        e3.openDoors();
                        e3.setMovingDirection("stopped"); 
                        departPersons(3, 3);
                        boardPersons(3, 3);
                    }
                }
            }





            /* up3 up3 up3 up3 up3 up3 up3 up3 up3 up3 up3 up3 up3 */
            if (e3.getNextCommand().Equals("up3"))
            {
                if (e3.getCurrentFloor() == 1 || e3.getCurrentFloor() == 2)
                {
                    if (e3.getPanel().Location.Y > 171)
                    {
                        if (e3.getDoorStatus().Equals("open"))
                        {
                            e3.closeDoors();
                        }
                        else if (e3.getDoorStatus().Equals("closed"))
                        {
                            e3.moveLift("up");
                            e3.setMovingDirection("up"); 
                        }
                    }
                    else
                    {
                        e3.removeCommand("up3");
                        turnLightOff(THIRD_FLOOR_UP_BTTN);
                        e3.setCurrentFloor(3);
                        e3.openDoors();
                        e3.setMovingDirection("stopped"); 
                        departPersons(3, 3);
                        boardPersons(3, 3);
                    }
                }
                else if (e3.getCurrentFloor() == 3)
                {
                    e3.removeCommand("up3");
                    turnLightOff(THIRD_FLOOR_UP_BTTN);
                    e3.setCurrentFloor(3);
                    e3.openDoors();
                    e3.setMovingDirection("stopped"); 
                    departPersons(3, 3);
                    boardPersons(3, 3);
                }
                else if (e3.getCurrentFloor() == 4 || e3.getCurrentFloor() == 5)
                {
                    if (e3.getPanel().Location.Y < 171)
                    {
                        if (e3.getDoorStatus().Equals("open"))
                        {
                            e3.closeDoors();
                        }
                        else if (e3.getDoorStatus().Equals("closed"))
                        {
                            e3.moveLift("down");
                            e3.setMovingDirection("down"); 
                        }
                    }
                    else
                    {
                        e3.removeCommand("up3");
                        turnLightOff(THIRD_FLOOR_UP_BTTN);
                        e3.setCurrentFloor(3);
                        e3.openDoors();
                        e3.setMovingDirection("stopped"); 
                        departPersons(3, 3);
                        boardPersons(3, 3);
                    }
                }
            }




            /* down4 down4 down4 down4 down4 down4 down4 down4 */
            if (e3.getNextCommand().Equals("down4"))
            {
                if (e3.getCurrentFloor() == 1 || e3.getCurrentFloor() == 2 || e3.getCurrentFloor() == 3)
                {
                    if (e3.getPanel().Location.Y > 88)
                    {
                        if (e3.getDoorStatus().Equals("open"))
                        {
                            e3.closeDoors();
                        }
                        else if (e3.getDoorStatus().Equals("closed"))
                        {
                            e3.moveLift("up");
                            e3.setMovingDirection("up"); 
                        }
                    }
                    else
                    {
                        e3.removeCommand("down4");
                        turnLightOff(FOURTH_FLOOR_DOWN_BTTN);
                        e3.setCurrentFloor(4);
                        e3.openDoors();
                        e3.setMovingDirection("stopped"); 
                        departPersons(4, 3);
                        boardPersons(4, 3);
                    }
                }
                else if (e3.getCurrentFloor() == 4)
                {
                    e3.removeCommand("down4");
                    turnLightOff(FOURTH_FLOOR_DOWN_BTTN);
                    e3.setCurrentFloor(4);
                    e3.openDoors();
                    e3.setMovingDirection("stopped"); 
                    departPersons(4, 3);
                    boardPersons(4, 3);
                }
                else if (e3.getCurrentFloor() == 5)
                {
                    if (e3.getPanel().Location.Y < 88)
                    {
                        if (e3.getDoorStatus().Equals("open"))
                        {
                            e3.closeDoors();
                        }
                        else if (e3.getDoorStatus().Equals("closed"))
                        {
                            e3.moveLift("down");
                            e3.setMovingDirection("down"); 
                        }
                    }
                    else
                    {
                        e3.removeCommand("down4");
                        turnLightOff(FOURTH_FLOOR_DOWN_BTTN);
                        e3.setCurrentFloor(4);
                        e3.openDoors();
                        e3.setMovingDirection("stopped"); 
                        departPersons(4, 3);
                        boardPersons(4, 3);
                    }
                }
            }




            /* up4 up4 up4 up4 up4 up4 up4 up4 up4 up4 up4 up4 */
            if (e3.getNextCommand().Equals("up4"))
            {
                if (e3.getCurrentFloor() == 1 || e3.getCurrentFloor() == 2 || e3.getCurrentFloor() == 3)
                {
                    if (e3.getPanel().Location.Y > 88)
                    {
                        if (e3.getDoorStatus().Equals("open"))
                        {
                            e3.closeDoors();
                        }
                        else if (e3.getDoorStatus().Equals("closed"))
                        {
                            e3.moveLift("up");
                            e3.setMovingDirection("up"); 
                        }
                    }
                    else
                    {
                        e3.removeCommand("up4");
                        turnLightOff(FOURTH_FLOOR_UP_BTTN);
                        e3.setCurrentFloor(4);
                        e3.openDoors();
                        e3.setMovingDirection("stopped"); 
                        departPersons(4, 3);
                        boardPersons(4, 3);
                    }
                }
                else if (e3.getCurrentFloor() == 4)
                {
                    e3.removeCommand("up4");
                    turnLightOff(FOURTH_FLOOR_UP_BTTN);
                    e3.setCurrentFloor(4);
                    e3.openDoors();
                    e3.setMovingDirection("stopped"); 
                    departPersons(4, 3);
                    boardPersons(4, 3);
                }
                else if (e3.getCurrentFloor() == 5)
                {
                    if (e3.getPanel().Location.Y < 88)
                    {
                        if (e3.getDoorStatus().Equals("open"))
                        {
                            e3.closeDoors();
                        }
                        else if (e3.getDoorStatus().Equals("closed"))
                        {
                            e3.moveLift("down");
                            e3.setMovingDirection("down"); 
                        }
                    }
                    else
                    {
                        e3.removeCommand("up4");
                        turnLightOff(FOURTH_FLOOR_UP_BTTN);
                        e3.setCurrentFloor(4);
                        e3.openDoors();
                        e3.setMovingDirection("stopped"); 
                        departPersons(4, 3);
                        boardPersons(4, 3);
                    }
                }
            }




            /* down5 down5 down5 down5 down5 down5 down5 down5 down5 */
            if (e3.getNextCommand().Equals("down5"))
            {
                if (e3.getCurrentFloor() == 1 || e3.getCurrentFloor() == 2 || e3.getCurrentFloor() == 3 || e3.getCurrentFloor() == 4)
                {
                    if (e3.getPanel().Location.Y > 1)
                    {
                        if (e3.getDoorStatus().Equals("open"))
                        {
                            e3.closeDoors();
                        }
                        else if (e3.getDoorStatus().Equals("closed"))
                        {
                            e3.moveLift("up");
                            e3.setMovingDirection("up"); 
                        }
                    }
                    else
                    {
                        e3.removeCommand("down5");
                        turnLightOff(FIFTH_FLOOR_DOWN_BTTN);
                        e3.setCurrentFloor(5);
                        e3.openDoors();
                        e3.setMovingDirection("stopped"); 
                        departPersons(5, 3);
                        boardPersons(5, 3);
                    }
                }
                else if (e3.getCurrentFloor() == 5)
                {
                    e3.removeCommand("down5");
                    turnLightOff(FIFTH_FLOOR_DOWN_BTTN);
                    e3.setCurrentFloor(5);
                    e3.openDoors();
                    e3.setMovingDirection("stopped"); 
                    departPersons(5, 3);
                    boardPersons(5, 3);
                }
            }




            /* floor1 floor1 floor1 floor1 floor1 floor1 floor1 floor1 floor1 */
            if (e3.getNextCommand().Equals("floor1"))
            {
                if (e3.getCurrentFloor() == 1)
                {
                    e3.removeCommand("floor1");
                    turnInternalLightOff(INTERNAL_LIFT3_FL1);
                    e3.setCurrentFloor(1);
                    e3.openDoors();
                    e3.setMovingDirection("stopped"); 
                    departPersons(1, 3);
                    boardPersons(1, 3);
                }
                else if (e3.getCurrentFloor() == 2 || e3.getCurrentFloor() == 3 || e3.getCurrentFloor() == 4 || e3.getCurrentFloor() == 5)
                {
                    if (e3.getPanel().Location.Y < 339)
                    {
                        if (e3.getDoorStatus().Equals("open"))
                        {
                            e3.closeDoors();
                        }
                        else if (e3.getDoorStatus().Equals("closed"))
                        {
                            e3.moveLift("down");
                            e3.setMovingDirection("down"); 
                        }
                    }
                    else
                    {
                        e3.removeCommand("floor1");
                        turnInternalLightOff(INTERNAL_LIFT3_FL1);
                        e3.setCurrentFloor(1);
                        e3.openDoors();
                        e3.setMovingDirection("stopped"); 
                        departPersons(1, 3);
                        boardPersons(1, 3);
                    }
                }
            }




            /* floor2 floor2 floor2 floor2 floor2 floor2 floor2 floor2 floor2 */
            if (e3.getNextCommand().Equals("floor2"))
            {
                if (e3.getCurrentFloor() == 1)
                {
                    if (e3.getPanel().Location.Y > 252)
                    {
                        if (e3.getDoorStatus().Equals("open"))
                        {
                            e3.closeDoors();
                        }
                        else if (e3.getDoorStatus().Equals("closed"))
                        {
                            e3.moveLift("up");
                            e3.setMovingDirection("up"); 
                        }
                    }
                    else
                    {
                        e3.removeCommand("floor2");
                        turnInternalLightOff(INTERNAL_LIFT3_FL2);
                        e3.setCurrentFloor(2);
                        e3.openDoors();
                        e3.setMovingDirection("stopped"); 
                        departPersons(2, 3);
                        boardPersons(2, 3);
                    }
                }
                else if (e3.getCurrentFloor() == 2)
                {
                    e3.removeCommand("floor2");
                    turnInternalLightOff(INTERNAL_LIFT3_FL2);
                    e3.setCurrentFloor(2);
                    e3.openDoors();
                    e3.setMovingDirection("stopped"); 
                    departPersons(2, 3);
                    boardPersons(2, 3);
                }
                else if (e3.getCurrentFloor() == 3 || e3.getCurrentFloor() == 4 || e3.getCurrentFloor() == 5)
                {
                    if (e3.getPanel().Location.Y < 252)
                    {
                        if (e3.getDoorStatus().Equals("open"))
                        {
                            e3.closeDoors();
                        }
                        else if (e3.getDoorStatus().Equals("closed"))
                        {
                            e3.moveLift("down");
                            e3.setMovingDirection("down"); 
                        }
                    }
                    else
                    {
                        e3.removeCommand("floor2");
                        turnInternalLightOff(INTERNAL_LIFT3_FL2);
                        e3.setCurrentFloor(2);
                        e3.openDoors();
                        e3.setMovingDirection("stopped"); 
                        departPersons(2, 3);
                        boardPersons(2, 3);
                    }
                }
            }



            /* floor3 floor3 floor3 floor3 floor3 floor3 floor3 floor3 floor3 */
            if (e3.getNextCommand().Equals("floor3"))
            {
                if (e3.getCurrentFloor() == 1 || e3.getCurrentFloor() == 2)
                {
                    if (e3.getPanel().Location.Y > 171)
                    {
                        if (e3.getDoorStatus().Equals("open"))
                        {
                            e3.closeDoors();
                        }
                        else if (e3.getDoorStatus().Equals("closed"))
                        {
                            e3.moveLift("up");
                            e3.setMovingDirection("up"); 
                        }
                    }
                    else
                    {
                        e3.removeCommand("floor3");
                        turnInternalLightOff(INTERNAL_LIFT3_FL3);
                        e3.setCurrentFloor(3);
                        e3.openDoors();
                        e3.setMovingDirection("stopped"); 
                        departPersons(3, 3);
                        boardPersons(3, 3);
                    }
                }
                else if (e3.getCurrentFloor() == 3)
                {
                    e3.removeCommand("floor3");
                    turnInternalLightOff(INTERNAL_LIFT3_FL3);
                    e3.setCurrentFloor(3);
                    e3.openDoors();
                    e3.setMovingDirection("stopped"); 
                    departPersons(3, 3);
                    boardPersons(3, 3);
                }
                else if (e3.getCurrentFloor() == 4 || e3.getCurrentFloor() == 5)
                {
                    if (e3.getPanel().Location.Y < 171)
                    {
                        if (e3.getDoorStatus().Equals("open"))
                        {
                            e3.closeDoors();
                        }
                        else if (e3.getDoorStatus().Equals("closed"))
                        {
                            e3.moveLift("down");
                            e3.setMovingDirection("down"); 
                        }
                    }
                    else
                    {
                        e3.removeCommand("floor3");
                        turnInternalLightOff(INTERNAL_LIFT3_FL3);
                        e3.setCurrentFloor(3);
                        e3.openDoors();
                        e3.setMovingDirection("stopped"); 
                        departPersons(3, 3);
                        boardPersons(3, 3);
                    }
                }
            }



            /* floor4 floor4 floor4 floor4 floor4 floor4 floor4 floor4 floor4 floor4 */
            if (e3.getNextCommand().Equals("floor4"))
            {
                if (e3.getCurrentFloor() == 1 || e3.getCurrentFloor() == 2 || e3.getCurrentFloor() == 3)
                {
                    if (e3.getPanel().Location.Y > 88)
                    {
                        if (e3.getDoorStatus().Equals("open"))
                        {
                            e3.closeDoors();
                        }
                        else if (e3.getDoorStatus().Equals("closed"))
                        {
                            e3.moveLift("up");
                            e3.setMovingDirection("up"); 
                        }
                    }
                    else
                    {
                        e3.removeCommand("floor4");
                        turnInternalLightOff(INTERNAL_LIFT3_FL4);
                        e3.setCurrentFloor(4);
                        e3.openDoors();
                        e3.setMovingDirection("stopped"); 
                        departPersons(4, 3);
                        boardPersons(4, 3);
                    }
                }
                else if (e3.getCurrentFloor() == 4)
                {
                    e3.removeCommand("floor4");
                    turnInternalLightOff(INTERNAL_LIFT3_FL4);
                    e3.setCurrentFloor(4);
                    e3.openDoors();
                    e3.setMovingDirection("stopped"); 
                    departPersons(4, 3);
                    boardPersons(4, 3);
                }
                else if (e3.getCurrentFloor() == 5)
                {
                    if (e3.getPanel().Location.Y < 88)
                    {
                        if (e3.getDoorStatus().Equals("open"))
                        {
                            e3.closeDoors();
                        }
                        else if (e3.getDoorStatus().Equals("closed"))
                        {
                            e3.moveLift("down");
                            e3.setMovingDirection("down"); 
                        }
                    }
                    else
                    {
                        e3.removeCommand("floor4");
                        turnInternalLightOff(INTERNAL_LIFT3_FL4);
                        e3.setCurrentFloor(4);
                        e3.openDoors();
                        e3.setMovingDirection("stopped"); 
                        departPersons(4, 3);
                        boardPersons(4, 3);
                    }
                }
            }



            /* floor5 floor5 floor5 floor5 floor5 floor5 floor5 floor5 floor5 floor5 */
            if (e3.getNextCommand().Equals("floor5"))
            {
                if (e3.getCurrentFloor() == 1 || e3.getCurrentFloor() == 2 || e3.getCurrentFloor() == 3 || e3.getCurrentFloor() == 4)
                {
                    if (e3.getPanel().Location.Y > 1)
                    {
                        if (e3.getDoorStatus().Equals("open"))
                        {
                            e3.closeDoors();
                        }
                        else if (e3.getDoorStatus().Equals("closed"))
                        {
                            e3.moveLift("up");
                            e3.setMovingDirection("up"); 
                        }
                    }
                    else
                    {
                        e3.removeCommand("floor5");
                        turnInternalLightOff(INTERNAL_LIFT3_FL5);
                        e3.setCurrentFloor(5);
                        e3.openDoors();
                        e3.setMovingDirection("stopped"); 
                        departPersons(5, 3);
                        boardPersons(5, 3);
                    }
                }
                else if (e3.getCurrentFloor() == 5)
                {
                    e3.removeCommand("floor5");
                    turnInternalLightOff(INTERNAL_LIFT3_FL5);
                    e3.setCurrentFloor(5);
                    e3.openDoors();
                    e3.setMovingDirection("stopped"); 
                    departPersons(5, 3);
                    boardPersons(5, 3);
                }
            }


        }

        /* The following controls relate to SimulationUI */

        private void addNewPerson(int floor)
        {
            string randomDestination = calcRandomDestination(floor);

            string[] newInstance = {"", cycleNo.ToString(), "yes", floor.ToString(), randomDestination.ToString()};
            simulationRecording.Add(newInstance); 

            if (floor == 1)
            {
                if (listFirstFloorWaitingPerson1.Count != 1)
                {
                    Person newPerson = new Person(nextID(), 1, randomDestination);
                    listFirstFloorWaitingPerson1.Add(newPerson);
                    if (pictureFloor1Person1Waiting.Image == null)
                    {
                        pictureFloor1Person1Waiting.Image = newPerson.getImage();
                        lblFloor1Person1Waiting.Text = newPerson.getLabel();
                        buttonPressed(FIRST_FLOOR_UP_BTTN); 
                    }
                }
                else if (listFirstFloorWaitingPerson2.Count != 1)
                {
                    Person newPerson = new Person(nextID(), 1, randomDestination);
                    listFirstFloorWaitingPerson2.Add(newPerson);
                    if (pictureFloor1Person2Waiting.Image == null)
                    {
                        pictureFloor1Person2Waiting.Image = newPerson.getImage();
                        lblFloor1Person2Waiting.Text = newPerson.getLabel();
                        buttonPressed(FIRST_FLOOR_UP_BTTN);
                    }
                }
            }
            else if (floor == 2)
            {
                if (listSecondFloorWaitingPerson1.Count != 1)
                {
                    Person newPerson = new Person(nextID(), 2, randomDestination);
                    listSecondFloorWaitingPerson1.Add(newPerson);
                    if (pictureFloor2Person1Waiting.Image == null)
                    {
                        pictureFloor2Person1Waiting.Image = newPerson.getImage();
                        lblFloor2Person1Waiting.Text = newPerson.getLabel();
                        if (newPerson.getDestinationFloor().Equals("1"))
                        {
                            buttonPressed(SECOND_FLOOR_DOWN_BTTN);
                        }
                        else
                        {
                            buttonPressed(SECOND_FLOOR_UP_BTTN);
                        }
                    }
                }
                else if (listSecondFloorWaitingPerson2.Count != 1)
                {
                    Person newPerson = new Person(nextID(), 2, randomDestination);
                    listSecondFloorWaitingPerson2.Add(newPerson);
                    if (pictureFloor2Person2Waiting.Image == null)
                    {
                        pictureFloor2Person2Waiting.Image = newPerson.getImage();
                        lblFloor2Person2Waiting.Text = newPerson.getLabel();
                        if (newPerson.getDestinationFloor().Equals("1"))
                        {
                            buttonPressed(SECOND_FLOOR_DOWN_BTTN);
                        }
                        else
                        {
                            buttonPressed(SECOND_FLOOR_UP_BTTN);
                        }
                    }
                }
            }
            else if (floor == 3)
            {
                if (listThirdFloorWaitingPerson1.Count != 1)
                {
                    Person newPerson = new Person(nextID(), 3, randomDestination);
                    listThirdFloorWaitingPerson1.Add(newPerson);
                    if (pictureFloor3Person1Waiting.Image == null)
                    {
                        pictureFloor3Person1Waiting.Image = newPerson.getImage();
                        lblFloor3Person1Waiting.Text = newPerson.getLabel();
                        if (newPerson.getDestinationFloor().Equals("1") || newPerson.getDestinationFloor().Equals("2"))
                        {
                            buttonPressed(THIRD_FLOOR_DOWN_BTTN);
                        }
                        else
                        {
                            buttonPressed(THIRD_FLOOR_UP_BTTN);
                        }
                    }
                }
                else if (listThirdFloorWaitingPerson2.Count != 1)
                {
                    Person newPerson = new Person(nextID(), 3, randomDestination);
                    listThirdFloorWaitingPerson2.Add(newPerson);
                    if (pictureFloor3Person2Waiting.Image == null)
                    {
                        pictureFloor3Person2Waiting.Image = newPerson.getImage();
                        lblFloor3Person2Waiting.Text = newPerson.getLabel();
                        if (newPerson.getDestinationFloor().Equals("1") || newPerson.getDestinationFloor().Equals("2"))
                        {
                            buttonPressed(THIRD_FLOOR_DOWN_BTTN);
                        }
                        else
                        {
                            buttonPressed(THIRD_FLOOR_UP_BTTN);
                        }
                    }
                }
            }
            else if (floor == 4)
            {
                if (listFourthFloorWaitingPerson1.Count != 1)
                {
                    Person newPerson = new Person(nextID(), 4, randomDestination);
                    listFourthFloorWaitingPerson1.Add(newPerson);
                    if (pictureFloor4Person1Waiting.Image == null)
                    {
                        pictureFloor4Person1Waiting.Image = newPerson.getImage();
                        lblFloor4Person1Waiting.Text = newPerson.getLabel();
                        if (newPerson.getDestinationFloor().Equals("1") || newPerson.getDestinationFloor().Equals("2") || newPerson.getDestinationFloor().Equals("3"))
                        {
                            buttonPressed(FOURTH_FLOOR_DOWN_BTTN);
                        }
                        else
                        {
                            buttonPressed(FOURTH_FLOOR_UP_BTTN);
                        }
                    }
                }
                else if (listFourthFloorWaitingPerson2.Count != 1)
                {
                    Person newPerson = new Person(nextID(), 4, randomDestination);
                    listFourthFloorWaitingPerson2.Add(newPerson);
                    if (pictureFloor4Person2Waiting.Image == null)
                    {
                        pictureFloor4Person2Waiting.Image = newPerson.getImage();
                        lblFloor4Person2Waiting.Text = newPerson.getLabel();
                        if (newPerson.getDestinationFloor().Equals("1") || newPerson.getDestinationFloor().Equals("2") || newPerson.getDestinationFloor().Equals("3"))
                        {
                            buttonPressed(FOURTH_FLOOR_DOWN_BTTN);
                        }
                        else
                        {
                            buttonPressed(FOURTH_FLOOR_UP_BTTN);
                        }
                    }
                }
            }
            else if (floor == 5)
            {
                if (listFifthFloorWaitingPerson1.Count != 1)
                {
                    Person newPerson = new Person(nextID(), 5, randomDestination);
                    listFifthFloorWaitingPerson1.Add(newPerson);
                    if (pictureFloor5Person1Waiting.Image == null)
                    {
                        pictureFloor5Person1Waiting.Image = newPerson.getImage();
                        lblFloor5Person1Waiting.Text = newPerson.getLabel();
                        buttonPressed(FIFTH_FLOOR_DOWN_BTTN);
                    }
                }
                else if (listFifthFloorWaitingPerson2.Count != 1)
                {
                    Person newPerson = new Person(nextID(), 5, randomDestination);
                    listFifthFloorWaitingPerson2.Add(newPerson);
                    if (pictureFloor5Person2Waiting.Image == null)
                    {
                        pictureFloor5Person2Waiting.Image = newPerson.getImage();
                        lblFloor5Person2Waiting.Text = newPerson.getLabel();
                        buttonPressed(FIFTH_FLOOR_DOWN_BTTN);
                    }
                }
            }
        }
        private void boardPersons(int floor, int elevator)
        {
            if (elevator == 1)
            {
                if (floor == 1)
                {
                    if (listFirstFloorWaitingPerson1.Count == 1)
                    {
                        if (e1.getCurrentFloor() == 1)
                        {
                            if (e1.getOccupantList(1).Count == 0)
                            {
                                pictureLift1Person1.Image = listFirstFloorWaitingPerson1[0].getImage();
                                lblLift1Person1.Text = listFirstFloorWaitingPerson1[0].getLabel();
                                pictureFloor1Person1Waiting.Image = null;
                                lblFloor1Person1Waiting.Text = ".";
                                e1.addOccupant(1, listFirstFloorWaitingPerson1[0]);
                                listFirstFloorWaitingPerson1.Remove(listFirstFloorWaitingPerson1[0]); 
                                queuePassengerFloor(elevator, e1.getOccupantList(1)[0]);
                            }
                        }
                    }
                    else if (listFirstFloorWaitingPerson2.Count == 1)
                    {
                        if (e1.getCurrentFloor() == 1)
                        {
                            if (e1.getOccupantList(2).Count == 0)
                            {
                                pictureLift1Person2.Image = listFirstFloorWaitingPerson2[0].getImage();
                                lblLift1Person2.Text = listFirstFloorWaitingPerson2[0].getLabel();
                                pictureFloor1Person2Waiting.Image = null;
                                lblFloor1Person2Waiting.Text = ".";
                                e1.addOccupant(2, listFirstFloorWaitingPerson2[0]);
                                listFirstFloorWaitingPerson2.Remove(listFirstFloorWaitingPerson2[0]); 
                                queuePassengerFloor(elevator, e1.getOccupantList(2)[0]);
                            }
                        }
                    }
                }
                else if (floor == 2)
                {
                    if (listSecondFloorWaitingPerson1.Count == 1)
                    {
                        if (e1.getCurrentFloor() == 2)
                        {
                            if (e1.getOccupantList(1).Count == 0)
                            {
                                pictureLift1Person1.Image = listSecondFloorWaitingPerson1[0].getImage();
                                lblLift1Person1.Text = listSecondFloorWaitingPerson1[0].getLabel();
                                pictureFloor2Person1Waiting.Image = null;
                                lblFloor2Person1Waiting.Text = ".";
                                e1.addOccupant(1, listSecondFloorWaitingPerson1[0]);
                                listSecondFloorWaitingPerson1.Remove(listSecondFloorWaitingPerson1[0]); 
                                queuePassengerFloor(elevator, e1.getOccupantList(1)[0]);
                            }
                        }
                    }
                    else if (listSecondFloorWaitingPerson2.Count == 1)
                    {
                        if (e1.getCurrentFloor() == 2)
                        {
                            if (e1.getOccupantList(2).Count == 0)
                            {
                                pictureLift1Person2.Image = listSecondFloorWaitingPerson2[0].getImage();
                                lblLift1Person2.Text = listSecondFloorWaitingPerson2[0].getLabel();
                                pictureFloor2Person2Waiting.Image = null;
                                lblFloor2Person2Waiting.Text = ".";
                                e1.addOccupant(2, listSecondFloorWaitingPerson2[0]);
                                listSecondFloorWaitingPerson2.Remove(listSecondFloorWaitingPerson2[0]); 
                                queuePassengerFloor(elevator, e1.getOccupantList(2)[0]);
                            }
                        }
                    }
                }
                else if (floor == 3)
                {
                    if (listThirdFloorWaitingPerson1.Count == 1)
                    {
                        if (e1.getCurrentFloor() == 3)
                        {
                            if (e1.getOccupantList(1).Count == 0)
                            {
                                pictureLift1Person1.Image = listThirdFloorWaitingPerson1[0].getImage();
                                lblLift1Person1.Text = listThirdFloorWaitingPerson1[0].getLabel();
                                pictureFloor3Person1Waiting.Image = null;
                                lblFloor3Person1Waiting.Text = ".";
                                e1.addOccupant(1, listThirdFloorWaitingPerson1[0]);
                                listThirdFloorWaitingPerson1.Remove(listThirdFloorWaitingPerson1[0]); 
                                queuePassengerFloor(elevator, e1.getOccupantList(1)[0]);
                            }
                        }
                    }

                    else if (listThirdFloorWaitingPerson2.Count == 1)
                    {
                        if (e1.getCurrentFloor() == 3)
                        {
                            if (e1.getOccupantList(2).Count == 0)
                            {
                                pictureLift1Person2.Image = listThirdFloorWaitingPerson2[0].getImage();
                                lblLift1Person2.Text = listThirdFloorWaitingPerson2[0].getLabel();
                                pictureFloor3Person2Waiting.Image = null;
                                lblFloor3Person2Waiting.Text = ".";
                                e1.addOccupant(2, listThirdFloorWaitingPerson2[0]);
                                listThirdFloorWaitingPerson2.Remove(listThirdFloorWaitingPerson2[0]); 
                                queuePassengerFloor(elevator, e1.getOccupantList(2)[0]);
                            }
                        }
                    }

                }
                else if (floor == 4)
                {
                    if (listFourthFloorWaitingPerson1.Count == 1)
                    {
                        if (e1.getCurrentFloor() == 4)
                        {
                            if (e1.getOccupantList(1).Count == 0)
                            {
                                pictureLift1Person1.Image = listFourthFloorWaitingPerson1[0].getImage();
                                lblLift1Person1.Text = listFourthFloorWaitingPerson1[0].getLabel();
                                pictureFloor4Person1Waiting.Image = null;
                                lblFloor4Person1Waiting.Text = ".";
                                e1.addOccupant(1, listFourthFloorWaitingPerson1[0]);
                                listFourthFloorWaitingPerson1.Remove(listFourthFloorWaitingPerson1[0]); 
                                queuePassengerFloor(elevator, e1.getOccupantList(1)[0]);
                            }
                        }
                    }

                    else if (listFourthFloorWaitingPerson2.Count == 1)
                    {
                        if (e1.getCurrentFloor() == 4)
                        {
                            if (e1.getOccupantList(2).Count == 0)
                            {
                                pictureLift1Person2.Image = listFourthFloorWaitingPerson2[0].getImage();
                                lblLift1Person2.Text = listFourthFloorWaitingPerson2[0].getLabel();
                                pictureFloor4Person2Waiting.Image = null;
                                lblFloor4Person2Waiting.Text = ".";
                                e1.addOccupant(2, listFourthFloorWaitingPerson2[0]);
                                listFourthFloorWaitingPerson2.Remove(listFourthFloorWaitingPerson2[0]); 
                                queuePassengerFloor(elevator, e1.getOccupantList(2)[0]);
                            }
                        }
                    }

                }
                else if (floor == 5)
                {
                    if (listFifthFloorWaitingPerson1.Count == 1)
                    {
                        if (e1.getCurrentFloor() == 5)
                        {
                            if (e1.getOccupantList(1).Count == 0)
                            {
                                pictureLift1Person1.Image = listFifthFloorWaitingPerson1[0].getImage();
                                lblLift1Person1.Text = listFifthFloorWaitingPerson1[0].getLabel();
                                pictureFloor5Person1Waiting.Image = null;
                                lblFloor5Person1Waiting.Text = ".";
                                e1.addOccupant(1, listFifthFloorWaitingPerson1[0]);
                                listFifthFloorWaitingPerson1.Remove(listFifthFloorWaitingPerson1[0]); 
                                queuePassengerFloor(elevator, e1.getOccupantList(1)[0]);
                            }
                        }
                    }

                    if (listFifthFloorWaitingPerson2.Count == 1)
                    {
                        if (e1.getCurrentFloor() == 5)
                        {
                            if (e1.getOccupantList(2).Count == 0)
                            {
                                pictureLift1Person2.Image = listFifthFloorWaitingPerson2[0].getImage();
                                lblLift1Person2.Text = listFifthFloorWaitingPerson2[0].getLabel();
                                pictureFloor5Person2Waiting.Image = null;
                                lblFloor5Person2Waiting.Text = ".";
                                e1.addOccupant(2, listFifthFloorWaitingPerson2[0]);
                                listFifthFloorWaitingPerson2.Remove(listFifthFloorWaitingPerson2[0]);
                                queuePassengerFloor(elevator, e1.getOccupantList(2)[0]);
                            }
                        }
                    }
                }
            }
            else if (elevator == 2)
            {
                if (floor == 1)
                {
                    if (listFirstFloorWaitingPerson1.Count == 1)
                    {
                        if (e2.getCurrentFloor() == 1)
                        {
                            if (e2.getOccupantList(1).Count == 0)
                            {
                                pictureLift2Person1.Image = listFirstFloorWaitingPerson1[0].getImage();
                                lblLift2Person1.Text = listFirstFloorWaitingPerson1[0].getLabel();
                                pictureFloor1Person1Waiting.Image = null;
                                lblFloor1Person1Waiting.Text = ".";
                                e2.addOccupant(1, listFirstFloorWaitingPerson1[0]);
                                listFirstFloorWaitingPerson1.Remove(listFirstFloorWaitingPerson1[0]); 
                                queuePassengerFloor(elevator, e2.getOccupantList(1)[0]);
                            }
                        }
                    }

                    if (listFirstFloorWaitingPerson2.Count == 1)
                    {
                        if (e2.getCurrentFloor() == 1)
                        {
                            if (e2.getOccupantList(2).Count == 0)
                            {
                                pictureLift2Person2.Image = listFirstFloorWaitingPerson2[0].getImage();
                                lblLift2Person2.Text = listFirstFloorWaitingPerson2[0].getLabel();
                                pictureFloor1Person2Waiting.Image = null;
                                lblFloor1Person2Waiting.Text = ".";
                                e2.addOccupant(2, listFirstFloorWaitingPerson2[0]);
                                listFirstFloorWaitingPerson2.Remove(listFirstFloorWaitingPerson2[0]); 
                                queuePassengerFloor(elevator, e2.getOccupantList(2)[0]);
                            }
                        }
                    }
                }
                else if (floor == 2)
                {
                    if (listSecondFloorWaitingPerson1.Count == 1)
                    {
                        if (e2.getCurrentFloor() == 2)
                        {
                            if (e2.getOccupantList(1).Count == 0)
                            {
                                pictureLift2Person1.Image = listSecondFloorWaitingPerson1[0].getImage();
                                lblLift2Person1.Text = listSecondFloorWaitingPerson1[0].getLabel();
                                pictureFloor2Person1Waiting.Image = null;
                                lblFloor2Person1Waiting.Text = ".";
                                e2.addOccupant(1, listSecondFloorWaitingPerson1[0]);
                                listSecondFloorWaitingPerson1.Remove(listSecondFloorWaitingPerson1[0]); 
                                queuePassengerFloor(elevator, e2.getOccupantList(1)[0]);
                            }
                        }
                    }

                    if (listSecondFloorWaitingPerson2.Count == 1)
                    {
                        if (e2.getCurrentFloor() == 2)
                        {
                            if (e2.getOccupantList(2).Count == 0)
                            {
                                pictureLift2Person2.Image = listSecondFloorWaitingPerson2[0].getImage();
                                lblLift2Person2.Text = listSecondFloorWaitingPerson2[0].getLabel();
                                pictureFloor2Person2Waiting.Image = null;
                                lblFloor2Person2Waiting.Text = ".";
                                e2.addOccupant(2, listSecondFloorWaitingPerson2[0]);
                                listSecondFloorWaitingPerson2.Remove(listSecondFloorWaitingPerson2[0]); 
                                queuePassengerFloor(elevator, e2.getOccupantList(2)[0]);
                            }
                        }
                    }
                }
                else if (floor == 3)
                {
                    if (listThirdFloorWaitingPerson1.Count == 1)
                    {
                        if (e2.getCurrentFloor() == 3)
                        {
                            if (e2.getOccupantList(1).Count == 0)
                            {
                                pictureLift2Person1.Image = listThirdFloorWaitingPerson1[0].getImage();
                                lblLift2Person1.Text = listThirdFloorWaitingPerson1[0].getLabel();
                                pictureFloor3Person1Waiting.Image = null;
                                lblFloor3Person1Waiting.Text = ".";
                                e2.addOccupant(1, listThirdFloorWaitingPerson1[0]);
                                listThirdFloorWaitingPerson1.Remove(listThirdFloorWaitingPerson1[0]); 
                                queuePassengerFloor(elevator, e2.getOccupantList(1)[0]);
                            }
                        }
                    }

                    if (listThirdFloorWaitingPerson2.Count == 1)
                    {
                        if (e2.getCurrentFloor() == 3)
                        {
                            if (e2.getOccupantList(2).Count == 0)
                            {
                                pictureLift2Person2.Image = listThirdFloorWaitingPerson2[0].getImage();
                                lblLift2Person2.Text = listThirdFloorWaitingPerson2[0].getLabel();
                                pictureFloor3Person2Waiting.Image = null;
                                lblFloor3Person2Waiting.Text = ".";
                                e2.addOccupant(2, listThirdFloorWaitingPerson2[0]);
                                listThirdFloorWaitingPerson2.Remove(listThirdFloorWaitingPerson2[0]); 
                                queuePassengerFloor(elevator, e2.getOccupantList(2)[0]);
                            }
                        }
                    }
                }
                else if (floor == 4)
                {
                    if (listFourthFloorWaitingPerson1.Count == 1)
                    {
                        if (e2.getCurrentFloor() == 4)
                        {
                            if (e2.getOccupantList(1).Count == 0)
                            {
                                pictureLift2Person1.Image = listFourthFloorWaitingPerson1[0].getImage();
                                lblLift2Person1.Text = listFourthFloorWaitingPerson1[0].getLabel();
                                pictureFloor4Person1Waiting.Image = null;
                                lblFloor4Person1Waiting.Text = ".";
                                e2.addOccupant(1, listFourthFloorWaitingPerson1[0]);
                                listFourthFloorWaitingPerson1.Remove(listFourthFloorWaitingPerson1[0]); 
                                queuePassengerFloor(elevator, e2.getOccupantList(1)[0]);
                            }
                        }
                    }

                    if (listFourthFloorWaitingPerson2.Count == 1)
                    {
                        if (e2.getCurrentFloor() == 4)
                        {
                            if (e2.getOccupantList(2).Count == 0)
                            {
                                pictureLift2Person2.Image = listFourthFloorWaitingPerson2[0].getImage();
                                lblLift2Person2.Text = listFourthFloorWaitingPerson2[0].getLabel();
                                pictureFloor4Person2Waiting.Image = null;
                                lblFloor4Person2Waiting.Text = ".";
                                e2.addOccupant(2, listFourthFloorWaitingPerson2[0]);
                                listFourthFloorWaitingPerson2.Remove(listFourthFloorWaitingPerson2[0]); 
                                queuePassengerFloor(elevator, e2.getOccupantList(2)[0]);
                            }
                        }
                    }
                }
                else if (floor == 5)
                {
                    if (listFifthFloorWaitingPerson1.Count == 1)
                    {
                        if (e2.getCurrentFloor() == 5)
                        {
                            if (e2.getOccupantList(1).Count == 0)
                            {
                                pictureLift2Person1.Image = listFifthFloorWaitingPerson1[0].getImage();
                                lblLift2Person1.Text = listFifthFloorWaitingPerson1[0].getLabel();
                                pictureFloor5Person1Waiting.Image = null;
                                lblFloor5Person1Waiting.Text = ".";
                                e2.addOccupant(1, listFifthFloorWaitingPerson1[0]);
                                listFifthFloorWaitingPerson1.Remove(listFifthFloorWaitingPerson1[0]); 
                                queuePassengerFloor(elevator, e2.getOccupantList(1)[0]);
                            }
                        }
                    }

                    if (listFifthFloorWaitingPerson2.Count == 1)
                    {
                        if (e2.getCurrentFloor() == 5)
                        {
                            if (e2.getOccupantList(2).Count == 0)
                            {
                                pictureLift2Person2.Image = listFifthFloorWaitingPerson2[0].getImage();
                                lblLift2Person2.Text = listFifthFloorWaitingPerson2[0].getLabel();
                                pictureFloor5Person2Waiting.Image = null;
                                lblFloor5Person2Waiting.Text = ".";
                                e2.addOccupant(2, listFifthFloorWaitingPerson2[0]);
                                listFifthFloorWaitingPerson2.Remove(listFifthFloorWaitingPerson2[0]); 
                                queuePassengerFloor(elevator, e2.getOccupantList(2)[0]);
                            }
                        }
                    }
                }
            }
            if (elevator == 3)
            {
                if (floor == 1)
                {
                    if (listFirstFloorWaitingPerson1.Count == 1)
                    {
                        if (e3.getCurrentFloor() == 1)
                        {
                            if (e3.getOccupantList(1).Count == 0)
                            {
                                pictureLift3Person1.Image = listFirstFloorWaitingPerson1[0].getImage();
                                lblLift3Person1.Text = listFirstFloorWaitingPerson1[0].getLabel();
                                pictureFloor1Person1Waiting.Image = null;
                                lblFloor1Person1Waiting.Text = ".";
                                e3.addOccupant(1, listFirstFloorWaitingPerson1[0]);
                                listFirstFloorWaitingPerson1.Remove(listFirstFloorWaitingPerson1[0]); 
                                queuePassengerFloor(elevator, e3.getOccupantList(1)[0]);
                            }
                        }
                    }

                    if (listFirstFloorWaitingPerson2.Count == 1)
                    {
                        if (e3.getCurrentFloor() == 1)
                        {
                            if (e3.getOccupantList(2).Count == 0)
                            {
                                pictureLift3Person2.Image = listFirstFloorWaitingPerson2[0].getImage();
                                lblLift3Person2.Text = listFirstFloorWaitingPerson2[0].getLabel();
                                pictureFloor1Person2Waiting.Image = null;
                                lblFloor1Person2Waiting.Text = ".";
                                e3.addOccupant(2, listFirstFloorWaitingPerson2[0]);
                                listFirstFloorWaitingPerson2.Remove(listFirstFloorWaitingPerson2[0]); 
                                queuePassengerFloor(elevator, e3.getOccupantList(2)[0]);
                            }
                        }
                    }
                }
                else if (floor == 2)
                {
                    if (listSecondFloorWaitingPerson1.Count == 1)
                    {
                        if (e3.getCurrentFloor() == 2)
                        {
                            if (e3.getOccupantList(1).Count == 0)
                            {
                                pictureLift3Person1.Image = listSecondFloorWaitingPerson1[0].getImage();
                                lblLift3Person1.Text = listSecondFloorWaitingPerson1[0].getLabel();
                                pictureFloor2Person1Waiting.Image = null;
                                lblFloor2Person1Waiting.Text = ".";
                                e3.addOccupant(1, listSecondFloorWaitingPerson1[0]);
                                listSecondFloorWaitingPerson1.Remove(listSecondFloorWaitingPerson1[0]); 
                                queuePassengerFloor(elevator, e3.getOccupantList(1)[0]);
                            }
                        }
                    }

                    if (listSecondFloorWaitingPerson2.Count == 1)
                    {
                        if (e3.getCurrentFloor() == 2)
                        {
                            if (e3.getOccupantList(2).Count == 0)
                            {
                                pictureLift3Person2.Image = listSecondFloorWaitingPerson2[0].getImage();
                                lblLift3Person2.Text = listSecondFloorWaitingPerson2[0].getLabel();
                                pictureFloor2Person2Waiting.Image = null;
                                lblFloor2Person2Waiting.Text = ".";
                                e3.addOccupant(2, listSecondFloorWaitingPerson2[0]);
                                listSecondFloorWaitingPerson2.Remove(listSecondFloorWaitingPerson2[0]); 
                                queuePassengerFloor(elevator, e3.getOccupantList(2)[0]);
                            }
                        }
                    }
                }
                else if (floor == 3)
                {
                    if (listThirdFloorWaitingPerson1.Count == 1)
                    {
                        if (e3.getCurrentFloor() == 3)
                        {
                            if (e3.getOccupantList(1).Count == 0)
                            {
                                pictureLift3Person1.Image = listThirdFloorWaitingPerson1[0].getImage();
                                lblLift3Person1.Text = listThirdFloorWaitingPerson1[0].getLabel();
                                pictureFloor3Person1Waiting.Image = null;
                                lblFloor3Person1Waiting.Text = ".";
                                e3.addOccupant(1, listThirdFloorWaitingPerson1[0]);
                                listThirdFloorWaitingPerson1.Remove(listThirdFloorWaitingPerson1[0]); 
                                queuePassengerFloor(elevator, e3.getOccupantList(1)[0]);
                            }
                        }
                    }

                    if (listThirdFloorWaitingPerson2.Count == 1)
                    {
                        if (e3.getCurrentFloor() == 3)
                        {
                            if (e3.getOccupantList(2).Count == 0)
                            {
                                pictureLift3Person2.Image = listThirdFloorWaitingPerson2[0].getImage();
                                lblLift3Person2.Text = listThirdFloorWaitingPerson2[0].getLabel();
                                pictureFloor3Person2Waiting.Image = null;
                                lblFloor3Person2Waiting.Text = ".";
                                e3.addOccupant(2, listThirdFloorWaitingPerson2[0]);
                                listThirdFloorWaitingPerson2.Remove(listThirdFloorWaitingPerson2[0]); 
                                queuePassengerFloor(elevator, e3.getOccupantList(2)[0]);
                            }
                        }
                    }
                }
                else if (floor == 4)
                {
                    if (listFourthFloorWaitingPerson1.Count == 1)
                    {
                        if (e3.getCurrentFloor() == 4)
                        {
                            if (e3.getOccupantList(1).Count == 0)
                            {
                                pictureLift3Person1.Image = listFourthFloorWaitingPerson1[0].getImage();
                                lblLift3Person1.Text = listFourthFloorWaitingPerson1[0].getLabel();
                                pictureFloor4Person1Waiting.Image = null;
                                lblFloor4Person1Waiting.Text = ".";
                                e3.addOccupant(1, listFourthFloorWaitingPerson1[0]);
                                listFourthFloorWaitingPerson1.Remove(listFourthFloorWaitingPerson1[0]); 
                                queuePassengerFloor(elevator, e3.getOccupantList(1)[0]);
                            }
                        }
                    }

                    if (listFourthFloorWaitingPerson2.Count == 1)
                    {
                        if (e3.getCurrentFloor() == 4)
                        {
                            if (e3.getOccupantList(2).Count == 0)
                            {
                                pictureLift3Person2.Image = listFourthFloorWaitingPerson2[0].getImage();
                                lblLift3Person2.Text = listFourthFloorWaitingPerson2[0].getLabel();
                                pictureFloor4Person2Waiting.Image = null;
                                lblFloor4Person2Waiting.Text = ".";
                                e3.addOccupant(2, listFourthFloorWaitingPerson2[0]);
                                listFourthFloorWaitingPerson2.Remove(listFourthFloorWaitingPerson2[0]); 
                                queuePassengerFloor(elevator, e3.getOccupantList(2)[0]);
                            }
                        }
                    }
                }
                else if (floor == 5)
                {
                    if (listFifthFloorWaitingPerson1.Count == 1)
                    {
                        if (e3.getCurrentFloor() == 5)
                        {
                            if (e3.getOccupantList(1).Count == 0)
                            {
                                pictureLift3Person1.Image = listFifthFloorWaitingPerson1[0].getImage();
                                lblLift3Person1.Text = listFifthFloorWaitingPerson1[0].getLabel();
                                pictureFloor5Person1Waiting.Image = null;
                                lblFloor5Person1Waiting.Text = ".";
                                e3.addOccupant(1, listFifthFloorWaitingPerson1[0]);
                                listFifthFloorWaitingPerson1.Remove(listFifthFloorWaitingPerson1[0]); 
                                queuePassengerFloor(elevator, e3.getOccupantList(1)[0]);
                            }
                        }
                    }

                    if (listFifthFloorWaitingPerson2.Count == 1)
                    {
                        if (e3.getCurrentFloor() == 5)
                        {
                            if (e3.getOccupantList(2).Count == 0)
                            {
                                pictureLift3Person2.Image = listFifthFloorWaitingPerson2[0].getImage();
                                lblLift3Person2.Text = listFifthFloorWaitingPerson2[0].getLabel();
                                pictureFloor5Person2Waiting.Image = null;
                                lblFloor5Person2Waiting.Text = ".";
                                e3.addOccupant(2, listFifthFloorWaitingPerson2[0]);
                                listFifthFloorWaitingPerson2.Remove(listFifthFloorWaitingPerson2[0]); 
                                queuePassengerFloor(elevator, e3.getOccupantList(2)[0]);
                            }
                        }
                    }
                }
            }

        }
        private void departPersons(int floor, int elevator)
        {
            if (elevator == 1)
            {
                if (floor == 1)
                {
                    if (e1.getOccupantList(1).Count == 1)
                    {
                        if (e1.getOccupantList(1)[0].getDestinationFloor().Equals("1"))
                        {
                            pictureFloor1Person1Departed.Image = e1.getOccupantList(1)[0].getImage();
                            lblFloor1Person1Departed.Text = e1.getOccupantList(1)[0].getLabel();
                            pictureLift1Person1.Image = null;
                            lblLift1Person1.Text = ".";

                            listFirstFloorDeparted.Add(e1.getOccupantList(1)[0]);
                            e1.emptyList(1);
                        }
                    }
                    if (e1.getOccupantList(2).Count == 1)
                    {
                        if (e1.getOccupantList(2)[0].getDestinationFloor().Equals("1"))
                        {
                            pictureFloor1Person2Departed.Image = e1.getOccupantList(2)[0].getImage();
                            lblFloor1Person2Departed.Text = e1.getOccupantList(2)[0].getLabel();
                            pictureLift1Person2.Image = null;
                            lblLift1Person2.Text = ".";

                            listFirstFloorDeparted.Add(e1.getOccupantList(2)[0]);
                            e1.emptyList(2);
                        }
                    }
                }

                else if (floor == 2)
                {
                    if (e1.getOccupantList(1).Count == 1)
                    {
                        if (e1.getOccupantList(1)[0].getDestinationFloor().Equals("2"))
                        {
                            pictureFloor2Person1Departed.Image = e1.getOccupantList(1)[0].getImage();
                            lblFloor2Person1Departed.Text = e1.getOccupantList(1)[0].getLabel();
                            pictureLift1Person1.Image = null;
                            lblLift1Person1.Text = ".";

                            listSecondFloorDeparted.Add(e1.getOccupantList(1)[0]);
                            e1.emptyList(1);
                        }
                    }
                    if (e1.getOccupantList(2).Count == 1)
                    {
                        if (e1.getOccupantList(2)[0].getDestinationFloor().Equals("2"))
                        {
                            pictureFloor2Person2Departed.Image = e1.getOccupantList(2)[0].getImage();
                            lblFloor2Person2Departed.Text = e1.getOccupantList(2)[0].getLabel();
                            pictureLift1Person2.Image = null;
                            lblLift1Person2.Text = ".";

                            listSecondFloorDeparted.Add(e1.getOccupantList(2)[0]);
                            e1.emptyList(2);
                        }
                    }
                }


                else if (floor == 3)
                {
                    if (e1.getOccupantList(1).Count == 1)
                    {
                        if (e1.getOccupantList(1)[0].getDestinationFloor().Equals("3"))
                        {
                            pictureFloor3Person1Departed.Image = e1.getOccupantList(1)[0].getImage();
                            lblFloor3Person1Departed.Text = e1.getOccupantList(1)[0].getLabel();
                            pictureLift1Person1.Image = null;
                            lblLift1Person1.Text = ".";

                            listThirdFloorDeparted.Add(e1.getOccupantList(1)[0]);
                            e1.emptyList(1);
                        }
                    }
                    if (e1.getOccupantList(2).Count == 1)
                    {
                        if (e1.getOccupantList(2)[0].getDestinationFloor().Equals("3"))
                        {
                            pictureFloor3Person2Departed.Image = e1.getOccupantList(2)[0].getImage();
                            lblFloor3Person2Departed.Text = e1.getOccupantList(2)[0].getLabel();
                            pictureLift1Person2.Image = null;
                            lblLift1Person2.Text = ".";

                            listThirdFloorDeparted.Add(e1.getOccupantList(2)[0]);
                            e1.emptyList(2);
                        }
                    }
                }

                if (floor == 4)
                {
                    if (e1.getOccupantList(1).Count == 1)
                    {
                        if (e1.getOccupantList(1)[0].getDestinationFloor().Equals("4"))
                        {
                            pictureFloor4Person1Departed.Image = e1.getOccupantList(1)[0].getImage();
                            lblFloor4Person1Departed.Text = e1.getOccupantList(1)[0].getLabel();
                            pictureLift1Person1.Image = null;
                            lblLift1Person1.Text = ".";

                            listFourthFloorDeparted.Add(e1.getOccupantList(1)[0]);
                            e1.emptyList(1);
                        }
                    }
                    if (e1.getOccupantList(2).Count == 1)
                    {
                        if (e1.getOccupantList(2)[0].getDestinationFloor().Equals("4"))
                        {
                            pictureFloor4Person2Departed.Image = e1.getOccupantList(2)[0].getImage();
                            lblFloor4Person2Departed.Text = e1.getOccupantList(2)[0].getLabel();
                            pictureLift1Person2.Image = null;
                            lblLift1Person2.Text = ".";

                            listFourthFloorDeparted.Add(e1.getOccupantList(2)[0]);
                            e1.emptyList(2);
                        }
                    }
                }


                if (floor == 5)
                {
                    if (e1.getOccupantList(1).Count == 1)
                    {
                        if (e1.getOccupantList(1)[0].getDestinationFloor().Equals("5"))
                        {
                            pictureFloor5Person1Departed.Image = e1.getOccupantList(1)[0].getImage();
                            lblFloor5Person1Departed.Text = e1.getOccupantList(1)[0].getLabel();
                            pictureLift1Person1.Image = null;
                            lblLift1Person1.Text = ".";

                            listFifthFloorDeparted.Add(e1.getOccupantList(1)[0]);
                            e1.emptyList(1);
                        }
                    }
                    if (e1.getOccupantList(2).Count == 1)
                    {
                        if (e1.getOccupantList(2)[0].getDestinationFloor().Equals("5"))
                        {
                            pictureFloor5Person2Departed.Image = e1.getOccupantList(2)[0].getImage();
                            lblFloor5Person2Departed.Text = e1.getOccupantList(2)[0].getLabel();
                            pictureLift1Person2.Image = null;
                            lblLift1Person2.Text = ".";

                            listFifthFloorDeparted.Add(e1.getOccupantList(2)[0]);
                            e1.emptyList(2);
                        }
                    }
                }

            }



            /* ELEVATOR 2 */
            if (elevator == 2)
            {
                if (floor == 1)
                {
                    if (e2.getOccupantList(1).Count == 1)
                    {
                        if (e2.getOccupantList(1)[0].getDestinationFloor().Equals("1"))
                        {
                            pictureFloor1Person1Departed.Image = e2.getOccupantList(1)[0].getImage();
                            lblFloor1Person1Departed.Text = e2.getOccupantList(1)[0].getLabel();
                            pictureLift2Person1.Image = null;
                            lblLift2Person1.Text = ".";

                            listFirstFloorDeparted.Add(e2.getOccupantList(1)[0]);
                            e2.emptyList(1);
                        }
                    }
                    if (e2.getOccupantList(2).Count == 1)
                    {
                        if (e2.getOccupantList(2)[0].getDestinationFloor().Equals("1"))
                        {
                            pictureFloor1Person2Departed.Image = e2.getOccupantList(2)[0].getImage();
                            lblFloor1Person2Departed.Text = e2.getOccupantList(2)[0].getLabel();
                            pictureLift2Person2.Image = null;
                            lblLift2Person2.Text = ".";

                            listFirstFloorDeparted.Add(e2.getOccupantList(2)[0]);
                            e2.emptyList(2);
                        }
                    }
                }

                else if (floor == 2)
                {
                    if (e2.getOccupantList(1).Count == 1)
                    {
                        if (e2.getOccupantList(1)[0].getDestinationFloor().Equals("2"))
                        {
                            pictureFloor2Person1Departed.Image = e2.getOccupantList(1)[0].getImage();
                            lblFloor2Person1Departed.Text = e2.getOccupantList(1)[0].getLabel();
                            pictureLift2Person1.Image = null;
                            lblLift2Person1.Text = ".";

                            listSecondFloorDeparted.Add(e2.getOccupantList(1)[0]);
                            e2.emptyList(1);
                        }
                    }
                    if (e2.getOccupantList(2).Count == 1)
                    {
                        if (e2.getOccupantList(2)[0].getDestinationFloor().Equals("2"))
                        {
                            pictureFloor2Person2Departed.Image = e2.getOccupantList(2)[0].getImage();
                            lblFloor2Person2Departed.Text = e2.getOccupantList(2)[0].getLabel();
                            pictureLift2Person2.Image = null;
                            lblLift2Person2.Text = ".";

                            listSecondFloorDeparted.Add(e2.getOccupantList(2)[0]);
                            e2.emptyList(2);
                        }
                    }
                }


                else if (floor == 3)
                {
                    if (e2.getOccupantList(1).Count == 1)
                    {
                        if (e2.getOccupantList(1)[0].getDestinationFloor().Equals("3"))
                        {
                            pictureFloor3Person1Departed.Image = e2.getOccupantList(1)[0].getImage();
                            lblFloor3Person1Departed.Text = e2.getOccupantList(1)[0].getLabel();
                            pictureLift2Person1.Image = null;
                            lblLift2Person1.Text = ".";

                            listThirdFloorDeparted.Add(e2.getOccupantList(1)[0]);
                            e2.emptyList(1);
                        }
                    }
                    if (e2.getOccupantList(2).Count == 1)
                    {
                        if (e2.getOccupantList(2)[0].getDestinationFloor().Equals("3"))
                        {
                            pictureFloor3Person2Departed.Image = e2.getOccupantList(2)[0].getImage();
                            lblFloor3Person2Departed.Text = e2.getOccupantList(2)[0].getLabel();
                            pictureLift2Person2.Image = null;
                            lblLift2Person2.Text = ".";

                            listThirdFloorDeparted.Add(e2.getOccupantList(2)[0]);
                            e2.emptyList(2);
                        }
                    }
                }

                if (floor == 4)
                {
                    if (e2.getOccupantList(1).Count == 1)
                    {
                        if (e2.getOccupantList(1)[0].getDestinationFloor().Equals("4"))
                        {
                            pictureFloor4Person1Departed.Image = e2.getOccupantList(1)[0].getImage();
                            lblFloor4Person1Departed.Text = e2.getOccupantList(1)[0].getLabel();
                            pictureLift2Person1.Image = null;
                            lblLift2Person1.Text = ".";

                            listFourthFloorDeparted.Add(e2.getOccupantList(1)[0]);
                            e2.emptyList(1);
                        }
                    }
                    if (e2.getOccupantList(2).Count == 1)
                    {
                        if (e2.getOccupantList(2)[0].getDestinationFloor().Equals("4"))
                        {
                            pictureFloor4Person2Departed.Image = e2.getOccupantList(2)[0].getImage();
                            lblFloor4Person2Departed.Text = e2.getOccupantList(2)[0].getLabel();
                            pictureLift2Person2.Image = null;
                            lblLift2Person2.Text = ".";

                            listFourthFloorDeparted.Add(e2.getOccupantList(2)[0]);
                            e2.emptyList(2);
                        }
                    }
                }


                if (floor == 5)
                {
                    if (e2.getOccupantList(1).Count == 1)
                    {
                        if (e2.getOccupantList(1)[0].getDestinationFloor().Equals("5"))
                        {
                            pictureFloor5Person1Departed.Image = e2.getOccupantList(1)[0].getImage();
                            lblFloor5Person1Departed.Text = e2.getOccupantList(1)[0].getLabel();
                            pictureLift2Person1.Image = null;
                            lblLift2Person1.Text = ".";

                            listFifthFloorDeparted.Add(e2.getOccupantList(1)[0]);
                            e2.emptyList(1);
                        }
                    }
                    if (e2.getOccupantList(2).Count == 1)
                    {
                        if (e2.getOccupantList(2)[0].getDestinationFloor().Equals("5"))
                        {
                            pictureFloor5Person2Departed.Image = e2.getOccupantList(2)[0].getImage();
                            lblFloor5Person2Departed.Text = e2.getOccupantList(2)[0].getLabel();
                            pictureLift2Person2.Image = null;
                            lblLift2Person2.Text = ".";

                            listFifthFloorDeparted.Add(e2.getOccupantList(2)[0]);
                            e2.emptyList(2);
                        }
                    }
                }

            }



            /* ELEVATOR 3 */
            if (elevator == 3)
            {
                if (floor == 1)
                {
                    if (e3.getOccupantList(1).Count == 1)
                    {
                        if (e3.getOccupantList(1)[0].getDestinationFloor().Equals("1"))
                        {
                            pictureFloor1Person1Departed.Image = e3.getOccupantList(1)[0].getImage();
                            lblFloor1Person1Departed.Text = e3.getOccupantList(1)[0].getLabel();
                            pictureLift3Person1.Image = null;
                            lblLift3Person1.Text = ".";

                            listFirstFloorDeparted.Add(e3.getOccupantList(1)[0]);
                            e3.emptyList(1);
                        }
                    }
                    if (e3.getOccupantList(2).Count == 1)
                    {
                        if (e3.getOccupantList(2)[0].getDestinationFloor().Equals("1"))
                        {
                            pictureFloor1Person2Departed.Image = e3.getOccupantList(2)[0].getImage();
                            lblFloor1Person2Departed.Text = e3.getOccupantList(2)[0].getLabel();
                            pictureLift3Person2.Image = null;
                            lblLift3Person2.Text = ".";

                            listFirstFloorDeparted.Add(e3.getOccupantList(2)[0]);
                            e3.emptyList(2);
                        }
                    }
                }

                else if (floor == 2)
                {
                    if (e3.getOccupantList(1).Count == 1)
                    {
                        if (e3.getOccupantList(1)[0].getDestinationFloor().Equals("2"))
                        {
                            pictureFloor2Person1Departed.Image = e3.getOccupantList(1)[0].getImage();
                            lblFloor2Person1Departed.Text = e3.getOccupantList(1)[0].getLabel();
                            pictureLift3Person1.Image = null;
                            lblLift3Person1.Text = ".";

                            listSecondFloorDeparted.Add(e3.getOccupantList(1)[0]);
                            e3.emptyList(1);
                        }
                    }
                    if (e3.getOccupantList(2).Count == 1)
                    {
                        if (e3.getOccupantList(2)[0].getDestinationFloor().Equals("2"))
                        {
                            pictureFloor2Person2Departed.Image = e3.getOccupantList(2)[0].getImage();
                            lblFloor2Person2Departed.Text = e3.getOccupantList(2)[0].getLabel();
                            pictureLift3Person2.Image = null;
                            lblLift3Person2.Text = ".";

                            listSecondFloorDeparted.Add(e3.getOccupantList(2)[0]);
                            e3.emptyList(2);
                        }
                    }
                }


                else if (floor == 3)
                {
                    if (e3.getOccupantList(1).Count == 1)
                    {
                        if (e3.getOccupantList(1)[0].getDestinationFloor().Equals("3"))
                        {
                            pictureFloor3Person1Departed.Image = e3.getOccupantList(1)[0].getImage();
                            lblFloor3Person1Departed.Text = e3.getOccupantList(1)[0].getLabel();
                            pictureLift3Person1.Image = null;
                            lblLift3Person1.Text = ".";

                            listThirdFloorDeparted.Add(e3.getOccupantList(1)[0]);
                            e3.emptyList(1);
                        }
                    }
                    if (e3.getOccupantList(2).Count == 1)
                    {
                        if (e3.getOccupantList(2)[0].getDestinationFloor().Equals("3"))
                        {
                            pictureFloor3Person2Departed.Image = e3.getOccupantList(2)[0].getImage();
                            lblFloor3Person2Departed.Text = e3.getOccupantList(2)[0].getLabel();
                            pictureLift3Person2.Image = null;
                            lblLift3Person2.Text = ".";

                            listThirdFloorDeparted.Add(e3.getOccupantList(2)[0]);
                            e3.emptyList(2);
                        }
                    }
                }

                if (floor == 4)
                {
                    if (e3.getOccupantList(1).Count == 1)
                    {
                        if (e3.getOccupantList(1)[0].getDestinationFloor().Equals("4"))
                        {
                            pictureFloor4Person1Departed.Image = e3.getOccupantList(1)[0].getImage();
                            lblFloor4Person1Departed.Text = e3.getOccupantList(1)[0].getLabel();
                            pictureLift3Person1.Image = null;
                            lblLift3Person1.Text = ".";

                            listFourthFloorDeparted.Add(e3.getOccupantList(1)[0]);
                            e3.emptyList(1);
                        }
                    }
                    if (e3.getOccupantList(2).Count == 1)
                    {
                        if (e3.getOccupantList(2)[0].getDestinationFloor().Equals("4"))
                        {
                            pictureFloor4Person2Departed.Image = e3.getOccupantList(2)[0].getImage();
                            lblFloor4Person2Departed.Text = e3.getOccupantList(2)[0].getLabel();
                            pictureLift3Person2.Image = null;
                            lblLift3Person2.Text = ".";

                            listFourthFloorDeparted.Add(e3.getOccupantList(2)[0]);
                            e3.emptyList(2);
                        }
                    }
                }


                if (floor == 5)
                {
                    if (e3.getOccupantList(1).Count == 1)
                    {
                        if (e3.getOccupantList(1)[0].getDestinationFloor().Equals("5"))
                        {
                            pictureFloor5Person1Departed.Image = e3.getOccupantList(1)[0].getImage();
                            lblFloor5Person1Departed.Text = e3.getOccupantList(1)[0].getLabel();
                            pictureLift3Person1.Image = null;
                            lblLift3Person1.Text = ".";

                            listFifthFloorDeparted.Add(e3.getOccupantList(1)[0]);
                            e3.emptyList(1);
                        }
                    }
                    if (e3.getOccupantList(2).Count == 1)
                    {
                        if (e3.getOccupantList(2)[0].getDestinationFloor().Equals("5"))
                        {
                            pictureFloor5Person2Departed.Image = e3.getOccupantList(2)[0].getImage();
                            lblFloor5Person2Departed.Text = e3.getOccupantList(2)[0].getLabel();
                            pictureLift3Person2.Image = null;
                            lblLift3Person2.Text = ".";

                            listFifthFloorDeparted.Add(e3.getOccupantList(2)[0]);
                            e3.emptyList(2);
                        }
                    }
                }

            }

        }
        private string calcRandomDestination(int floor)
        {
            Random random = new Random();
            string returnValue = "";

            int next = getNextRandom(); 
            while (next == floor)
            {
                next = getNextRandom(); 
            }
            returnValue = "" + next;
            return returnValue; 


        }
        private int getNextRandom()
        {
            Random random = new Random(); 
            int max = maxFloors + 1; 
            return random.Next(1, max);
        }
        private int nextID()
        {
            personID += 1;
            return personID;
        }
        private void bttnStartSim_Click(object sender, EventArgs e)
        {
            timeElapsed.Enabled = true;
            timeElapsed.Start(); 
            cycleNo = 0;
            personID = 0; 
            bttnLoad.Enabled = false; 
            if (radio2seconds.Checked)
            {
                simulationTimer.Interval = 2000; 
            }
            else if (radio4seconds.Checked)
            {
                simulationTimer.Interval = 4000; 
            }
            else if (radio6seconds.Checked)
            {
                simulationTimer.Interval = 6000; 
            }
            else if (radio8seconds.Checked)
            {
                simulationTimer.Interval = 8000;
            }
            simulationTimer.Start(); 

        }
        private void button1_Click(object sender, EventArgs e)
        {
            boardPersons(1, 1);
        }
        private void button2_Click(object sender, EventArgs e)
        {
            departPersons(e1.getCurrentFloor(), 1);
        }
        private void liftUpdater_Tick(object sender, EventArgs e)
        {
            lblLift1CurrentFloor.Text = "Current floor: " + e1.getCurrentFloor();
            lblLift2CurrentFloor.Text = "Current floor: " + e2.getCurrentFloor();
            lblLift3CurrentFloor.Text = "Current floor: " + e3.getCurrentFloor();

            lblLift1MovingDirection.Text = "Moving direction: " + e1.getMovingDirection();
            lblLift2MovingDirection.Text = "Moving direction: " + e2.getMovingDirection();
            lblLift3MovingDirection.Text = "Moving direction: " + e3.getMovingDirection();

            lblLift1TotalWeight.Text = "Total weight: " + e1.getWeight() + "kg";
            lblLift2TotalWeight.Text = "Total weight: " + e2.getWeight() + "kg";
            lblLift3TotalWeight.Text = "Total weight: " + e3.getWeight() + "kg";

            lblTimeElapsed.Text = "Time elasped: " + totalTimeElapsed + "s";
            lblTotalPeople.Text = "No. of people using lifts: " + getTotalPeople();
        }

        private int getTotalPeople()
        {
            int counter = 0;
            counter += listFirstFloorWaitingPerson1.Count;
            counter += listFirstFloorWaitingPerson2.Count;
            counter += listSecondFloorWaitingPerson1.Count;
            counter += listSecondFloorWaitingPerson2.Count;
            counter += listThirdFloorWaitingPerson1.Count;
            counter += listThirdFloorWaitingPerson2.Count;
            counter += listFourthFloorWaitingPerson1.Count;
            counter += listFourthFloorWaitingPerson2.Count;
            counter += listFifthFloorWaitingPerson1.Count;
            counter += listFifthFloorWaitingPerson2.Count;
            counter += e1.getOccupantList(1).Count;
            counter += e1.getOccupantList(2).Count;
            counter += e2.getOccupantList(1).Count;
            counter += e2.getOccupantList(2).Count;
            counter += e3.getOccupantList(1).Count;
            counter += e3.getOccupantList(2).Count;
            counter += listFirstFloorDeparted.Count;
            counter += listSecondFloorDeparted.Count;
            counter += listThirdFloorDeparted.Count;
            counter += listFourthFloorDeparted.Count;
            counter += listFifthFloorDeparted.Count;
            return counter;
        }
        private void queuePassengerFloor(int elevatorNumber, Person p)
        {
            if (elevatorNumber == 1)
            {
                if (p.getDestinationFloor().Equals("1"))
                {
                    internalButtonPressed(INTERNAL_LIFT1_FL1);
                }
                else if (p.getDestinationFloor().Equals("2"))
                {
                    internalButtonPressed(INTERNAL_LIFT1_FL2);
                }
                else if (p.getDestinationFloor().Equals("3"))
                {
                    internalButtonPressed(INTERNAL_LIFT1_FL3);
                }
                else if (p.getDestinationFloor().Equals("4"))
                {
                    internalButtonPressed(INTERNAL_LIFT1_FL4);
                }
                else if (p.getDestinationFloor().Equals("5"))
                {
                    internalButtonPressed(INTERNAL_LIFT1_FL5);
                }
            }
            else if (elevatorNumber == 2)
            {
                if (p.getDestinationFloor().Equals("1"))
                {
                    internalButtonPressed(INTERNAL_LIFT2_FL1);
                }
                else if (p.getDestinationFloor().Equals("2"))
                {
                    internalButtonPressed(INTERNAL_LIFT2_FL2);
                }
                else if (p.getDestinationFloor().Equals("3"))
                {
                    internalButtonPressed(INTERNAL_LIFT2_FL3);
                }
                else if (p.getDestinationFloor().Equals("4"))
                {
                    internalButtonPressed(INTERNAL_LIFT2_FL4);
                }
                else if (p.getDestinationFloor().Equals("5"))
                {
                    internalButtonPressed(INTERNAL_LIFT2_FL5);
                }
            }
            else if (elevatorNumber == 3)
            {
                if (p.getDestinationFloor().Equals("1"))
                {
                    internalButtonPressed(INTERNAL_LIFT3_FL1);
                }
                else if (p.getDestinationFloor().Equals("2"))
                {
                    internalButtonPressed(INTERNAL_LIFT3_FL2);
                }
                else if (p.getDestinationFloor().Equals("3"))
                {
                    internalButtonPressed(INTERNAL_LIFT3_FL3);
                }
                else if (p.getDestinationFloor().Equals("4"))
                {
                    internalButtonPressed(INTERNAL_LIFT3_FL4);
                }
                else if (p.getDestinationFloor().Equals("5"))
                {
                    internalButtonPressed(INTERNAL_LIFT3_FL5);
                }
            }
        }
        private void buttonPressers_Tick(object sender, EventArgs e)
        {
            if (listFirstFloorWaitingPerson1.Count != 0)
            {
                foreach (Person p in listFirstFloorWaitingPerson1)
                {
                    buttonPressed(FIRST_FLOOR_UP_BTTN); 
                }
            }
            if (listFirstFloorWaitingPerson2.Count != 0)
            {
                foreach (Person p in listFirstFloorWaitingPerson2)
                {
                    buttonPressed(FIRST_FLOOR_UP_BTTN);
                }
            }
            if (listSecondFloorWaitingPerson1.Count != 0)
            {
                foreach (Person p in listSecondFloorWaitingPerson1)
                {
                    if (p.getDestinationFloor().Equals("1"))
                    {
                        buttonPressed(SECOND_FLOOR_DOWN_BTTN); 
                    }
                    else 
                    {
                        buttonPressed(SECOND_FLOOR_UP_BTTN); 
                    }
                }
            }
            if (listSecondFloorWaitingPerson2.Count != 0)
            {
                foreach (Person p in listSecondFloorWaitingPerson2)
                {
                    if (p.getDestinationFloor().Equals("1"))
                    {
                        buttonPressed(SECOND_FLOOR_DOWN_BTTN);
                    }
                    else
                    {
                        buttonPressed(SECOND_FLOOR_UP_BTTN);
                    }
                }
            }
            if (listThirdFloorWaitingPerson1.Count != 0)
            {
                foreach (Person p in listThirdFloorWaitingPerson1)
                {
                    if (p.getDestinationFloor().Equals("1") || p.getDestinationFloor().Equals("2"))
                    {
                        buttonPressed(THIRD_FLOOR_DOWN_BTTN); 
                    }
                    else
                    {
                        buttonPressed(THIRD_FLOOR_UP_BTTN); 
                    }
                }
            }
            if (listThirdFloorWaitingPerson2.Count != 0)
            {
                foreach (Person p in listThirdFloorWaitingPerson2)
                {
                    if (p.getDestinationFloor().Equals("1") || p.getDestinationFloor().Equals("2"))
                    {
                        buttonPressed(THIRD_FLOOR_DOWN_BTTN);
                    }
                    else
                    {
                        buttonPressed(THIRD_FLOOR_UP_BTTN);
                    }
                }
            }
            if (listFourthFloorWaitingPerson1.Count != 0)
            {
                foreach (Person p in listFourthFloorWaitingPerson1)
                {
                    if (p.getDestinationFloor().Equals("1") || p.getDestinationFloor().Equals("2") || p.getDestinationFloor().Equals("3"))
                    {
                        buttonPressed(FOURTH_FLOOR_DOWN_BTTN); 
                    }
                    else
                    {
                        buttonPressed(FOURTH_FLOOR_UP_BTTN); 
                    }
                }
            }
            if (listFourthFloorWaitingPerson2.Count != 0)
            {
                foreach (Person p in listFourthFloorWaitingPerson2)
                {
                    if (p.getDestinationFloor().Equals("1") || p.getDestinationFloor().Equals("2") || p.getDestinationFloor().Equals("3"))
                    {
                        buttonPressed(FOURTH_FLOOR_DOWN_BTTN);
                    }
                    else
                    {
                        buttonPressed(FOURTH_FLOOR_UP_BTTN);
                    }
                }
            }
            if (listFifthFloorWaitingPerson1.Count != 0)
            {
                foreach (Person p in listFifthFloorWaitingPerson1)
                {
                    buttonPressed(FIFTH_FLOOR_DOWN_BTTN);
                }
            }
            if (listFifthFloorWaitingPerson2.Count != 0)
            {
                foreach (Person p in listFifthFloorWaitingPerson2)
                {
                    buttonPressed(FIFTH_FLOOR_DOWN_BTTN);
                }
            }
        }
        private void simulationTimer_Tick(object sender, EventArgs e)
        {
            cycleNo++; 
            clearDeparted();
            int prob = probabilityBar.Value;
            Random random = new Random();
            if (random.Next(1, 11) <= prob)
            {
                int floor = random.Next(1, maxFloors + 1);
                if (floor == 1)
                {
                    addNewPerson(1);
                }
                else if (floor == 2)
                {
                    addNewPerson(2);
                }
                else if (floor == 3)
                {
                    addNewPerson(3);
                }
                else if (floor == 4)
                {
                    addNewPerson(4);
                }
                else if (floor == 5)
                {
                    addNewPerson(5);
                }
            }
            else
            {
                string[] newInstance = { "", cycleNo.ToString(), "no", "0", "0" };
                simulationRecording.Add(newInstance); 
            }
        }
        private void bttnStopSim_Click(object sender, EventArgs e)
        {
            timeElapsed.Stop(); 
            timeElapsed.Enabled = false; 
            simulationTimer.Enabled = false;
            databaseConnect(); 
            bttnLoad.Enabled = true;
            backToPriorState();
            totalTimeElapsed = 0;

        }
        private void backToPriorState()
        {
            listFirstFloorWaitingPerson1.Clear();
            listFirstFloorWaitingPerson2.Clear();
            listSecondFloorWaitingPerson1.Clear();
            listSecondFloorWaitingPerson2.Clear();
            listThirdFloorWaitingPerson1.Clear();
            listThirdFloorWaitingPerson2.Clear();
            listFourthFloorWaitingPerson1.Clear();
            listFourthFloorWaitingPerson2.Clear();
            listFifthFloorWaitingPerson1.Clear();
            listFifthFloorWaitingPerson2.Clear();
            listFirstFloorDeparted.Clear();
            listSecondFloorDeparted.Clear();
            listThirdFloorDeparted.Clear();
            listFourthFloorDeparted.Clear();
            listFifthFloorDeparted.Clear();
            e1.emptyList(1);
            e1.emptyList(2);
            e2.emptyList(1);
            e2.emptyList(2);
            e3.emptyList(1);
            e3.emptyList(2);
            e1.emptyCommands();
            e2.emptyCommands();
            e3.emptyCommands();
            setupFloorNaming();
            setupNumberFloors();
            setupNumberLifts();
            turnLightOff(FIRST_FLOOR_UP_BTTN);
            turnLightOff(SECOND_FLOOR_DOWN_BTTN);
            turnLightOff(SECOND_FLOOR_UP_BTTN);
            turnLightOff(THIRD_FLOOR_DOWN_BTTN);
            turnLightOff(THIRD_FLOOR_UP_BTTN);
            turnLightOff(FOURTH_FLOOR_DOWN_BTTN);
            turnLightOff(FOURTH_FLOOR_UP_BTTN);
            turnLightOff(FIFTH_FLOOR_DOWN_BTTN);
            turnInternalLightOff(INTERNAL_LIFT1_FL1);
            turnInternalLightOff(INTERNAL_LIFT1_FL2);
            turnInternalLightOff(INTERNAL_LIFT1_FL3);
            turnInternalLightOff(INTERNAL_LIFT1_FL4);
            turnInternalLightOff(INTERNAL_LIFT1_FL5);
            turnInternalLightOff(INTERNAL_LIFT2_FL1);
            turnInternalLightOff(INTERNAL_LIFT2_FL2);
            turnInternalLightOff(INTERNAL_LIFT2_FL3);
            turnInternalLightOff(INTERNAL_LIFT2_FL4);
            turnInternalLightOff(INTERNAL_LIFT2_FL5);
            turnInternalLightOff(INTERNAL_LIFT3_FL1);
            turnInternalLightOff(INTERNAL_LIFT3_FL2);
            turnInternalLightOff(INTERNAL_LIFT3_FL3);
            turnInternalLightOff(INTERNAL_LIFT3_FL4);
            turnInternalLightOff(INTERNAL_LIFT3_FL5);
            pictureFloor1Person1Waiting.Image = null;
            pictureFloor1Person2Waiting.Image = null;
            pictureFloor2Person1Waiting.Image = null;
            pictureFloor2Person2Waiting.Image = null;
            pictureFloor3Person1Waiting.Image = null;
            pictureFloor3Person2Waiting.Image = null;
            pictureFloor4Person1Waiting.Image = null;
            pictureFloor4Person2Waiting.Image = null;
            pictureFloor5Person1Waiting.Image = null;
            pictureFloor5Person2Waiting.Image = null;
            pictureFloor1Person1Departed.Image = null;
            pictureFloor1Person2Departed.Image = null;
            pictureFloor2Person1Departed.Image = null;
            pictureFloor2Person2Departed.Image = null;
            pictureFloor3Person1Departed.Image = null;
            pictureFloor3Person2Departed.Image = null;
            pictureFloor4Person1Departed.Image = null;
            pictureFloor4Person2Departed.Image = null;
            pictureFloor5Person1Departed.Image = null;
            pictureFloor5Person2Departed.Image = null;
            pictureLift1Person1.Image = null;
            pictureLift1Person2.Image = null;
            pictureLift2Person1.Image = null;
            pictureLift2Person2.Image = null;
            pictureLift3Person1.Image = null;
            pictureLift3Person2.Image = null;
            lblFloor1Person1Waiting.Text = ".";
            lblFloor1Person2Waiting.Text = ".";
            lblFloor2Person1Waiting.Text = ".";
            lblFloor2Person2Waiting.Text = ".";
            lblFloor3Person1Waiting.Text = ".";
            lblFloor3Person2Waiting.Text = ".";
            lblFloor4Person1Waiting.Text = ".";
            lblFloor4Person2Waiting.Text = ".";
            lblFloor5Person1Waiting.Text = ".";
            lblFloor5Person2Waiting.Text = ".";
            lblFloor1Person1Departed.Text = ".";
            lblFloor1Person2Departed.Text = ".";
            lblFloor2Person1Departed.Text = ".";
            lblFloor2Person2Departed.Text = ".";
            lblFloor3Person1Departed.Text = ".";
            lblFloor3Person2Departed.Text = ".";
            lblFloor4Person1Departed.Text = ".";
            lblFloor4Person2Departed.Text = ".";
            lblFloor5Person1Departed.Text = ".";
            lblFloor5Person2Departed.Text = ".";
            lblLift1Person1.Text = ".";
            lblLift1Person2.Text = ".";
            lblLift2Person1.Text = ".";
            lblLift2Person2.Text = ".";
            lblLift3Person1.Text = ".";
            lblLift3Person2.Text = ".";
            e1.setDoors("closed");
            e2.setDoors("closed");
            e3.setDoors("closed");
            resetLifts(); 
        }
        private void databaseConnect()
        {
            DialogResult result1 = MessageBox.Show("Save results to database?", "Question", MessageBoxButtons.YesNo);
            if (result1 == DialogResult.Yes)
            {
                new insertName(this).ShowDialog(); 
                foreach (string[] x in simulationRecording)
                {
                    x[0] = simName; 
                }

                foreach (string[] y in simulationRecording)
                {
                    new MySQLConnector().saveData(y); 
                }
                setupSavedSims(); 
            }
            else
            {
                simulationRecording.Clear(); 
            }

        }
        private void clearDeparted()
        {
            if (listFirstFloorDeparted.Count != 0)
            {
                listFirstFloorDeparted.Clear();
                pictureFloor1Person1Departed.Image = null;
                pictureFloor1Person2Departed.Image = null;
                lblFloor1Person1Departed.Text = ".";
                lblFloor1Person2Departed.Text = ".";
            }
            if (listSecondFloorDeparted.Count != 0)
            {
                listSecondFloorDeparted.Clear();
                pictureFloor2Person1Departed.Image = null;
                pictureFloor2Person2Departed.Image = null;
                lblFloor2Person1Departed.Text = ".";
                lblFloor2Person2Departed.Text = ".";
            }
            if (listThirdFloorDeparted.Count != 0)
            {
                listThirdFloorDeparted.Clear();
                pictureFloor3Person1Departed.Image = null;
                pictureFloor3Person2Departed.Image = null;
                lblFloor3Person1Departed.Text = ".";
                lblFloor3Person2Departed.Text = ".";
            }
            if (listFourthFloorDeparted.Count != 0)
            {
                listFourthFloorDeparted.Clear();
                pictureFloor4Person1Departed.Image = null;
                pictureFloor4Person2Departed.Image = null;
                lblFloor4Person1Departed.Text = ".";
                lblFloor4Person2Departed.Text = ".";
            }
            if (listFifthFloorDeparted.Count != 0)
            {
                listFifthFloorDeparted.Clear();
                pictureFloor5Person1Departed.Image = null;
                pictureFloor5Person2Departed.Image = null;
                lblFloor5Person1Departed.Text = ".";
                lblFloor5Person2Departed.Text = ".";
            }
        }

        private void bttnLoad_Click(object sender, EventArgs e)
        {
            if (savedSims.SelectedItem != null)
            {
                cycleNo = 0;
                personID = 1;
                loadedSimulation = new MySQLConnector().getSimSteps(savedSims.SelectedItem.ToString());
                runLoaded.Enabled = true;
                runLoaded.Start();
            }
            else
            {
                MessageBox.Show("You need to actually select the simulation first (click on it)."); 
            }
        }
        private void runLoaded_Tick(object sender, EventArgs e)
        {
            if (cycleNo < loadedSimulation.Count)
            {
                string[] row = loadedSimulation[cycleNo];
                if (row[2].Equals("yes"))
                {
                    addGuy(row[3], row[4]);
                    cycleNo++; 
                }
                else
                {
                    cycleNo++; 
                }
            }
            else
            {
                runLoaded.Enabled = false;
                MessageBox.Show("Simulation replay completed!"); 
            }
        }
        private void addGuy(string origin, string destination)
        {
            int enter = 0; 
            if (origin.Equals("1"))
            {
                enter = 1;
            }
            else if (origin.Equals("2"))
            {
                enter = 2; 
            }
            else if (origin.Equals("3"))
            {
                enter = 3;
            }
            else if (origin.Equals("4"))
            {
                enter = 4;
            }
            else if (origin.Equals("5"))
            {
                enter = 5; 
            }
            Person newPerson = new Person(nextID(), enter, destination);
            if (enter == 1)
            {
                if (listFirstFloorWaitingPerson1.Count != 1)
                {
                    listFirstFloorWaitingPerson1.Add(newPerson);
                    if (pictureFloor1Person1Waiting.Image == null)
                    {
                        pictureFloor1Person1Waiting.Image = newPerson.getImage();
                        lblFloor1Person1Waiting.Text = newPerson.getLabel();
                        buttonPressed(FIRST_FLOOR_UP_BTTN);
                    }
                }
                else if (listFirstFloorWaitingPerson2.Count != 1)
                {
                    listFirstFloorWaitingPerson2.Add(newPerson);
                    if (pictureFloor1Person2Waiting.Image == null)
                    {
                        pictureFloor1Person2Waiting.Image = newPerson.getImage();
                        lblFloor1Person2Waiting.Text = newPerson.getLabel();
                        buttonPressed(FIRST_FLOOR_UP_BTTN);
                    }
                }
            }
            else if (enter == 2)
            {
                if (listSecondFloorWaitingPerson1.Count != 1)
                {
                    listSecondFloorWaitingPerson1.Add(newPerson);
                    if (pictureFloor2Person1Waiting.Image == null)
                    {
                        pictureFloor2Person1Waiting.Image = newPerson.getImage();
                        lblFloor2Person1Waiting.Text = newPerson.getLabel();
                        if (newPerson.getDestinationFloor().Equals("1"))
                        {
                            buttonPressed(SECOND_FLOOR_DOWN_BTTN);
                        }
                        else
                        {
                            buttonPressed(SECOND_FLOOR_UP_BTTN);
                        }
                    }
                }
                else if (listSecondFloorWaitingPerson2.Count != 1)
                {
                    listSecondFloorWaitingPerson2.Add(newPerson);
                    if (pictureFloor2Person2Waiting.Image == null)
                    {
                        pictureFloor2Person2Waiting.Image = newPerson.getImage();
                        lblFloor2Person2Waiting.Text = newPerson.getLabel();
                        if (newPerson.getDestinationFloor().Equals("1"))
                        {
                            buttonPressed(SECOND_FLOOR_DOWN_BTTN);
                        }
                        else
                        {
                            buttonPressed(SECOND_FLOOR_UP_BTTN);
                        }
                    }
                }
            }
            else if (enter == 3)
            {
                if (listThirdFloorWaitingPerson1.Count != 1)
                {
                    listThirdFloorWaitingPerson1.Add(newPerson);
                    if (pictureFloor3Person1Waiting.Image == null)
                    {
                        pictureFloor3Person1Waiting.Image = newPerson.getImage();
                        lblFloor3Person1Waiting.Text = newPerson.getLabel();
                        if (newPerson.getDestinationFloor().Equals("1") || newPerson.getDestinationFloor().Equals("2"))
                        {
                            buttonPressed(THIRD_FLOOR_DOWN_BTTN);
                        }
                        else
                        {
                            buttonPressed(THIRD_FLOOR_UP_BTTN);
                        }
                    }
                }
                else if (listThirdFloorWaitingPerson2.Count != 1)
                {
                    listThirdFloorWaitingPerson2.Add(newPerson);
                    if (pictureFloor3Person2Waiting.Image == null)
                    {
                        pictureFloor3Person2Waiting.Image = newPerson.getImage();
                        lblFloor3Person2Waiting.Text = newPerson.getLabel();
                        if (newPerson.getDestinationFloor().Equals("1") || newPerson.getDestinationFloor().Equals("2"))
                        {
                            buttonPressed(THIRD_FLOOR_DOWN_BTTN);
                        }
                        else
                        {
                            buttonPressed(THIRD_FLOOR_UP_BTTN);
                        }
                    }
                }
            }
            else if (enter == 4)
            {
                if (listFourthFloorWaitingPerson1.Count != 1)
                {
                    listFourthFloorWaitingPerson1.Add(newPerson);
                    if (pictureFloor4Person1Waiting.Image == null)
                    {
                        pictureFloor4Person1Waiting.Image = newPerson.getImage();
                        lblFloor4Person1Waiting.Text = newPerson.getLabel();
                        if (newPerson.getDestinationFloor().Equals("1") || newPerson.getDestinationFloor().Equals("2") || newPerson.getDestinationFloor().Equals("3"))
                        {
                            buttonPressed(FOURTH_FLOOR_DOWN_BTTN);
                        }
                        else
                        {
                            buttonPressed(FOURTH_FLOOR_UP_BTTN);
                        }
                    }
                }
                else if (listFourthFloorWaitingPerson2.Count != 1)
                {
                    listFourthFloorWaitingPerson2.Add(newPerson);
                    if (pictureFloor4Person2Waiting.Image == null)
                    {
                        pictureFloor4Person2Waiting.Image = newPerson.getImage();
                        lblFloor4Person2Waiting.Text = newPerson.getLabel();
                        if (newPerson.getDestinationFloor().Equals("1") || newPerson.getDestinationFloor().Equals("2") || newPerson.getDestinationFloor().Equals("3"))
                        {
                            buttonPressed(FOURTH_FLOOR_DOWN_BTTN);
                        }
                        else
                        {
                            buttonPressed(FOURTH_FLOOR_UP_BTTN);
                        }
                    }
                }
            }
            else if (enter == 5)
            {
                if (listFifthFloorWaitingPerson1.Count != 1)
                {
                    listFifthFloorWaitingPerson1.Add(newPerson);
                    if (pictureFloor5Person1Waiting.Image == null)
                    {
                        pictureFloor5Person1Waiting.Image = newPerson.getImage();
                        lblFloor5Person1Waiting.Text = newPerson.getLabel();
                        buttonPressed(FIFTH_FLOOR_DOWN_BTTN);
                    }
                }
                else if (listFifthFloorWaitingPerson2.Count != 1)
                {
                    listFifthFloorWaitingPerson2.Add(newPerson);
                    if (pictureFloor5Person2Waiting.Image == null)
                    {
                        pictureFloor5Person2Waiting.Image = newPerson.getImage();
                        lblFloor5Person2Waiting.Text = newPerson.getLabel();
                        buttonPressed(FIFTH_FLOOR_DOWN_BTTN);
                    }
                }
            }
        }

        private void bttnLift1OpenDoors_Click(object sender, EventArgs e)
        {
            e1.openDoors(); 
        }
        private void bttnLift1CloseDoors_Click(object sender, EventArgs e)
        {
            e1.closeDoors(); 
        }
        private void bttnLift2OpenDoors_Click(object sender, EventArgs e)
        {
            e2.openDoors(); 
        }
        private void bttnLift2CloseDoors_Click(object sender, EventArgs e)
        {
            e2.closeDoors(); 
        }
        private void bttnLift3OpenDoors_Click(object sender, EventArgs e)
        {
            e3.openDoors(); 
        }
        private void bttnLift3CloseDoors_Click(object sender, EventArgs e)
        {
            e3.closeDoors(); 
        }

        private void bttnDefault_Click(object sender, EventArgs e)
        {
            radio3lifts.Checked = true;
            radio5floors.Checked = true;
            radioUS.Checked = true; 
        }

        private void bttnRandomize_Click(object sender, EventArgs e)
        {
            Random random = new Random();
            int randLifts = random.Next(0, 3);
            if (randLifts == 0)
            {
                radio1lift.Checked = true; 
            }
            else if (randLifts == 1)
            {
                radio2lifts.Checked = true; 
            }
            else if (randLifts == 2)
            {
                radio3lifts.Checked = true; 
            }
            int randFloors = random.Next(0, 4);
            if (randFloors == 0)
            {
                radio2floors.Checked = true; 
            }
            else if (randFloors == 1)
            {
                radio3floors.Checked = true; 
            }
            else if (randFloors == 2)
            {
                radio4floors.Checked = true; 
            }
            else if (randFloors == 3)
            {
                radio5floors.Checked = true;
            }
            int randNaming = random.Next(0, 2);
            if (randNaming == 0)
            {
                radioUK.Checked = true;
            }
            else if (randNaming == 1)
            {
                radioUS.Checked = true; 
            }
        }

        private void bttnLift1Alarm_Click(object sender, EventArgs e)
        {
            Thread soundThread = new Thread(new ThreadStart(playAlarm));
            soundThread.Start(); 
        }
        private void bttnLift2Alarm_Click(object sender, EventArgs e)
        {
            Thread soundThread = new Thread(new ThreadStart(playAlarm));
            soundThread.Start();
        }
        private void bttnLift3Alarm_Click(object sender, EventArgs e)
        {
            SoundPlayer alarm = new SoundPlayer(@"C:\Users\Adrian\Desktop\BachelorIT\2011_SP2\CP2013 - Software Engineering\elevator\images\alarm.wav");
            alarm.Play();
        }
        private void playAlarm()
        {
            SoundPlayer alarm = new SoundPlayer(@"C:\Users\Adrian\Desktop\BachelorIT\2011_SP2\CP2013 - Software Engineering\elevator\images\alarm.wav");
            alarm.Play();
        }

        private void timeElapsed_Tick(object sender, EventArgs e)
        {
            totalTimeElapsed++; 
        }
        
    }
}
               
